elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Problemas tilde en PHP.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problemas tilde en PHP.  (Leído 2,371 veces)
.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Problemas tilde en PHP.
« en: 24 Julio 2012, 23:02 pm »

Hola a todos tengo el siguiente lector de RSS de facebook, este funciona la perfección, el problema es que los tildes no me los muestra correctamente, ¿alguien podría echarme una mano?

Código
  1. <?php
  2.    // Without this "ini_set" Facebook's RSS url is all screwy for reading!
  3.    // This is the most essential line, don't forget it.
  4.    ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9');
  5.  
  6.    // This URL is the URL to the Facebook Page's RSS feed.
  7.    // Go to the page's profile, and on the left-hand side click "Get Updates vis RSS"
  8.    $rssUrl = "http://www.facebook.com/feeds/notifications.php?id=319579974767006&viewer=1074983523&key=AWhjAKL7r9fCfZlH&format=rss20";
  9.    $xml = simplexml_load_file($rssUrl); // Load the XML file
  10.  
  11.    // This creates an array called "entry" that puts each <item> in FB's
  12.    // XML format into the array
  13.    $entry = $xml->channel->item;
  14.  
  15.    // This is just a blank string I create to add to as I loop through our
  16.    // FB feed. Feel free to format however you want, or do whatever else
  17.    // you want with the data.
  18.    $returnMarkup = '';
  19.  
  20.    // Now we'll loop through are array. I just have it going up to 3 items
  21.    // for this example.
  22.    for ($i = 0; $i < 3; $i++) {
  23.        //$returnMarkup .= "<h3>".$entry[$i]->title."</h3>"; // Title of the update
  24.        //$returnMarkup .= "<p>".$entry[$i]->link."</p>"; // Link to the update
  25.        $returnMarkup .= "<p>".$entry[$i]->description."</p>"; // Full content
  26.        //$returnMarkup .= "<p>".$entry[$i]->pubDate."</p>"; // The date published
  27.        $returnMarkup .= "<p>".$entry[$i]->author."</p>"; // The author (Page Title)
  28.    }
  29.  
  30.    // Finally, we return (or in this case echo) our formatted string with our
  31.    // Facebook page feed data in it!
  32.    echo $returnMarkup;
  33. ?>

Saludos


En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
Spider-Net


Desconectado Desconectado

Mensajes: 1.165


Un gran poder conlleva una gran responsabilidad


Ver Perfil WWW
Re: Problemas tilde en PHP.
« Respuesta #1 en: 24 Julio 2012, 23:58 pm »

Tiene que ver con la codificación. Lo ideal es que cambies la codificación de utf-8 a ISO-8859-1. Otra solución que debería funcionar es usar htmlentities cuando vayas a mostrar la información, algo así:

Código
  1. for ($i = 0; $i < 3; $i++) {
  2.        //$returnMarkup .= "<h3>".$entry[$i]->title."</h3>"; // Title of the update
  3.        //$returnMarkup .= "<p>".$entry[$i]->link."</p>"; // Link to the update
  4.        $returnMarkup .= "<p>".htmlentities($entry[$i]->description)."</p>"; // Full content
  5.        //$returnMarkup .= "<p>".$entry[$i]->pubDate."</p>"; // The date published
  6.        $returnMarkup .= "<p>".htmlentities($entry[$i]->author)."</p>"; // The author (Page Title)
  7. }


En línea

.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Re: Problemas tilde en PHP.
« Respuesta #2 en: 25 Julio 2012, 05:55 am »

Tiene que ver con la codificación. Lo ideal es que cambies la codificación de utf-8 a ISO-8859-1. Otra solución que debería funcionar es usar htmlentities cuando vayas a mostrar la información, algo así:

Código
  1. for ($i = 0; $i < 3; $i++) {
  2.        //$returnMarkup .= "<h3>".$entry[$i]->title."</h3>"; // Title of the update
  3.        //$returnMarkup .= "<p>".$entry[$i]->link."</p>"; // Link to the update
  4.        $returnMarkup .= "<p>".htmlentities($entry[$i]->description)."</p>"; // Full content
  5.        //$returnMarkup .= "<p>".$entry[$i]->pubDate."</p>"; // The date published
  6.        $returnMarkup .= "<p>".htmlentities($entry[$i]->author)."</p>"; // The author (Page Title)
  7. }

Gracias por tu respuesta, pero htmlentities me devuelve el código en texto plano (lo bueno es que con tildes), que podría hacer?

Modifiqué la codificación con header(), también he hecho un echo con
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> y tampoco nada, a ver quien me ayuda, saludos

SOLUCIONADO: utf8_decode();
« Última modificación: 25 Julio 2012, 06:12 am por .:UND3R:. » En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
problemas Nero-problemas Roxio-problemas sonido de PC
Multimedia
mohabe 1 3,565 Último mensaje 5 Abril 2006, 04:47 am
por fer63
listas enlazadas problemas resueltos todo un paquete de 13 problemas
Java
fiisi 4 55,379 Último mensaje 9 Junio 2009, 02:25 am
por sapito169
Problemas con el virus de la doble tilde
Seguridad
gabrach 7 8,428 Último mensaje 7 Diciembre 2010, 22:30 pm
por gabrach
Auto Login problema con la tilde
.NET (C#, VB.NET, ASP)
j0selit0_vaca 7 5,765 Último mensaje 1 Octubre 2011, 06:24 am
por j0selit0_vaca
Como buscar sin tilde un registro con tilde
Bases de Datos
ElInquisidor 1 2,555 Último mensaje 7 Noviembre 2015, 02:36 am
por 0roch1
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines