Page 1 of 1

define('') with a $var

Posted: Tue Sep 14, 2004 7:32 pm
by hawleyjr
Why is it:

Code: Select all

<?php
define("UPDATED_USER","You have successfully updated the profile for $name.");
?>
Works on my personal server.

But doesn't work on my work server?

The error:

Code: Select all

Notice: Undefined variable: name

Posted: Tue Sep 14, 2004 7:34 pm
by John Cartwright
That's only a notice, meaning it is working fine. But $name has not been set yet. The reason why it shows up on your server is because you have your error_reporting set to E_ALL. I recommend always having E_ALL on, it will save your hours and hours of scratching your head..

Posted: Tue Sep 14, 2004 7:34 pm
by feyd
.....and $name is set..... magically?

Posted: Tue Sep 14, 2004 7:35 pm
by nigma
Because $name is undefined :)

No, just joking. I've got no idea. But what happens if you do a die("$name") right before the call to define() that produces the error?