string concept: is this for php?
Posted: Fri Jul 29, 2005 9:00 am
function Alert($str)
{
echo("<script language='javascript'>");
echo("alert('$str');");
echo("</script>");
}
//no error
$str="Hello peter";
Alert($str);
//error
$str="Hello peter's cats";
Alert($str);
error code is: Expected ';'
I guess problem is the ' in $str, which makes actural look in second line of fuction Alert() as:
"alert('Hello peter's cats');"
so quote perter's stops (ends) first quote alert('
is that true?
how do u solve this kind problem?
{
echo("<script language='javascript'>");
echo("alert('$str');");
echo("</script>");
}
//no error
$str="Hello peter";
Alert($str);
//error
$str="Hello peter's cats";
Alert($str);
error code is: Expected ';'
I guess problem is the ' in $str, which makes actural look in second line of fuction Alert() as:
"alert('Hello peter's cats');"
so quote perter's stops (ends) first quote alert('
is that true?
how do u solve this kind problem?