ricosalomar Posted December 5, 2007 Share Posted December 5, 2007 I'm getting an error: Undefined variable: PHP_SELF in my error.log. But the code that it's pointing to is: <a href="<? $_SERVER['PHP_SELF'] ?>?var=foo">Bar</a> I thought that was correct. Obviously, I'm mistaken, can anyone help? Rico Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/ Share on other sites More sharing options...
cooldude832 Posted December 5, 2007 Share Posted December 5, 2007 well where to start A) You are trying to create an output with no output function defined B) You didn't finish a phrase C) Had that been a complete phrase you didn't use a semi colon D) You used Short tags try <html> <a href="<?php echo $_SERVER['PHP_SELF'];?>"?var=foo">Bar</a> </html> Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/#findComment-406504 Share on other sites More sharing options...
btherl Posted December 5, 2007 Share Posted December 5, 2007 Are you 100% sure that that is the code generating the error? Does PHP_SELF occur anywhere in any of your other code? Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/#findComment-406507 Share on other sites More sharing options...
trq Posted December 5, 2007 Share Posted December 5, 2007 You really don't need $_SERVER['PHP_SELF anyway.... <a href="?var=foo">Bar</a> will do. Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/#findComment-406549 Share on other sites More sharing options...
bibby Posted December 5, 2007 Share Posted December 5, 2007 Undefined variable is a Notice , yes? Not a Fatal Error, not a Warning. IMO, PHP's error reporting level is too high. Undefined variables could be checked all the time in normal situations, and shouldn't really be sent to the screen unless you really intend it to. Dig my reply to this post, where the problem may have been that the level was too low. http://www.phpfreaks.com/forums/index.php/topic,170596.0.html error_reporting(7) (same as error_reporting(E_ERROR | E_WARNING | E_PARSE) ) is a good level for reporting true problems, and not silly notices Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/#findComment-406592 Share on other sites More sharing options...
ricosalomar Posted December 5, 2007 Author Share Posted December 5, 2007 Bibby, you are correct, they are notices, not errors. But my log is so full of them, it'd be nice to slim it down a bit. btherl, the log points to that code, by line #. My code is loaded with similar calls to PHP_SELF. Thorpe, I'll try that. cooldude832, this is the way it should look, thanks. BTW, the page(s) render correctly, and function correctly. I just wanted to get to the bottom of the logs. Thank you all for your help. -Rico Quote Link to comment https://forums.phpfreaks.com/topic/80202-solved-undefined-variable-silliness/#findComment-406885 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.