Foros del Web » Programando para Internet » PHP »

Me pueder revisar el codigo

Estas en el tema de Me pueder revisar el codigo en el foro de PHP en Foros del Web. Hola chicos soy nueva en php de hecho es mi segundo programa lo trascribi de un libro que estoy leyendo, pero al ejecutarlo no me ...
  #1 (permalink)  
Antiguo 12/06/2010, 11:35
 
Fecha de Ingreso: abril-2010
Mensajes: 21
Antigüedad: 14 años
Puntos: 1
Me pueder revisar el codigo

Hola chicos soy nueva en php de hecho es mi segundo programa lo trascribi de un libro que estoy leyendo, pero al ejecutarlo no me muestra nada, ya anteriormente hice uno y si se ejecuto correctamente, quiero creer que es error de sintaxis me podrian ayudar?? cabe mencionar que tambien agregue codigo html.

Código PHP:
<html>
<head>
<title> Beginning PHP5</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<table width="100%" border="1">
<tr>
<td width="49%"><font face="Arial, Helvetica, sans-serif"><b>Working
Whith Strings</b></font></td>
<td width="51%">&nbsp;</td>
</tr>
<tr>
<td width="49%"><font face="Arial, Helvetica, sans-serif" size="-1">Using Concatenation - the . operator</font></td>
<td width="51%"><font face="Arial, Helvetica, sans-serif" size="-1">

<?php
$first_name 
"Joe";
$last_name "Blow";
$whole_name $first_name " " $last_name;
echo 
"First name plus last name = <b>$whole_name</b>";
?>

</font></td>
</tr>
<tr>
<td width="49%"><font face="Arial, Helvetica, sans-serif" size="-1">
Finding
String Length - using <b>strlen()</b></font></td>
<td width="51%"><font face="Arial, Helvetica, sans-serif" size="-1">
<?php
$string_length 
strlen($whole name);
echo 
"the length of the name is <b>" $string_length "</b>";
?>
</font></td>
</tr>
<tr>
<td width ="49%"><font face="Arial, Helvetica, sans-serif" size="-1">Getting part of a String - using <b>strstr()</b></font></td>
<td width="51%"><font face="Arial, Helvatica, sans-serif" size="-1">
<?php
$part_after_space 
strstr($whole_name" ");
echo 
"The part of the string after the space is <b>" $part_after_space "</b>";
?>
</font></td>
</tr>
<tr>
<td width="49%"><font face="Arial, Helvetica, sans-serif" size="-1">Finding Position of Part of a String - using <b>strpos()</b></font></td>
<td width="51%"><font face="Arial, Helvetica, sans-serif" size="-1">
<?php
$letter_position 
strpos($whole_name"o");
echo 
"The position of the letter &quot;o&quot; is <b>" $letter_position "</br>";
?>
</font></td>
</tr>
<tr>
<td width="49%"><font face="Arial, Helvetica, sans-serif" size="-1">Return a character based on an ASCII value - using <b>chr()</b></font></td>
<td width="51%"><font face="Arial, Helvetica, sans-serif" size="-1">
<?php
$ascii_character_returned 
chr(97);
echo 
"The character corresponding to ASCII decimal value 97 is <b>" $ascii_character_returned "</b>";
?>
</font></td>
</tr>
</table>
</body>
</html>
  #2 (permalink)  
Antiguo 12/06/2010, 11:48
Avatar de santris  
Fecha de Ingreso: agosto-2009
Ubicación: Sant Feliu de Llobregat
Mensajes: 955
Antigüedad: 14 años, 8 meses
Puntos: 66
Respuesta: Me pueder revisar el codigo

El código parece estar bien, por qué no pruebas ha ejecutarlo por partes.

primero ejecutas esto:

Código PHP:
<?php
$first_name 
"Joe";
$last_name "Blow";
$whole_name $first_name " " $last_name;
echo 
"First name plus last name = <b>$whole_name</b>";
?>
y si te imprime el echo sigues con el resto hasta encontrar el fallo.
__________________
Tu álbum de cromos online!!

Última edición por santris; 12/06/2010 a las 12:30
  #3 (permalink)  
Antiguo 12/06/2010, 13:27
Avatar de Kaze71  
Fecha de Ingreso: enero-2010
Mensajes: 44
Antigüedad: 14 años, 3 meses
Puntos: 4
Respuesta: Me pueder revisar el codigo

Fíjate en esta línea:
Código PHP:
$string_length strlen($whole name); 
Pusiste un espacio en el nombre de la variable que pasaste a strlen.

Saludos;
__________________
unset($noise);
  #4 (permalink)  
Antiguo 21/08/2010, 11:27
 
Fecha de Ingreso: abril-2010
Mensajes: 21
Antigüedad: 14 años
Puntos: 1
Respuesta: Me pueder revisar el codigo

Hola Kaze 2 meses despues, pero muchas gracias eso era lo que me estaba fallando el guion bajo en la variable, ya me ejecuto sin problemas.

mil gracias

Etiquetas: revisar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:53.