PHP Header() help...

Status
Not open for further replies.


Nope. :)
When you use single quotes, it doesn't replace variables. So
Code:
$foo='bar';
print '$foo';
prints '$foo'.

Good for dollar amounts but not so good for printing 'bar'. :)
It's one tip for making your code faster; if you have a block of text with no variables to assign to another variable, use single quotes and php won't evaluate it for variables which takes valuable microseconds. :)
 
  • Like
Reactions: JoeZ
ah thanks...didn't know that.

Got another quick question while you are here...

Any idea why a cookie would work on one system and not another when the person it isn't working on tells me their cookies are enabled and work?
 
prob easier to talk on AIM if you don't mind....


setcookie("uniqueid", $id); //sets cookie
$id = $HTTP_COOKIE_VARS["uniqueid"]; //reads cookie

worked for 2 people, didn't for one
 
Oddly enough, I just tested this test.php page and it worked upon refresh perfectly on all variables...

PHP:
<?php
$name = "Success!";
setcookie("id", "", time()-300000);
setcookie("id", $name);
echo $HTTP_COOKIE_VARS["id"];
echo "<-One <br>";
echo $_COOKIE["id"];
echo "<-Two <br>";
echo $id;
echo "<-Three";
echo "<br><br>";
print_r($_COOKIE);

?>
 
No...the person is a close friend so I know they weren't messing with me. That script worked, but using the same code in my real script didn't work. The setcookie didn't seem to work in the real script, but did in the test..
 
Status
Not open for further replies.