define('') with a $var

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

define('') with a $var

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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..
Last edited by John Cartwright on Tue Sep 14, 2004 7:36 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

.....and $name is set..... magically?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post 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?
Post Reply