Can any one tell me why this code doesn't work?
$bodytag = str_replace("id=\"", "id=1\"",
"$p = $_GET['p'];
echo '<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.php?id=$p\">';
");
Thanks in advance!
Is this what you are meaning to do?
$p = (int)$_GET['p'];
echo '<link rel="stylesheet" type="text/css" href="styles.php?id='.$p.'">';
$bodytag = str_replace('id="', 'id='.$_GET['p'].'"','style.php?id="');
echo '<link rel="stylesheet" type="text/css" href="'.$bodytag.'">';
Dont know why you escape the " in the echo, cause you use ' to print the link-tag. if you want /" to be in you url instead of ", just add it to the code
/edit: sry, didn't think about what i wrote. Just saw the mistake without looking through my stuff. But Ing's solutions is way better. Just remember the syntax to use str_replace.