Trek15 Posted April 16, 2009 Share Posted April 16, 2009 I get the T_PUBLIC error with this code but the guy who helped me with it says that it works for him in both PHP 4 and 5. What's up with that?? Thank you. <?php public $content; if (!$content['user']['is_guest']) { echo '<li><a href="javascript:loadintoIframe(\'frame\', \'https://www.download.com\')"></a></li>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/ Share on other sites More sharing options...
premiso Posted April 16, 2009 Share Posted April 16, 2009 Variable context/scope is only used in Classes/OOP in php as far as I know (public private etc) As classes can distinguish/hide that information. PHP on it's own without the use of the class cannot really distinguish it. Why he does not see the error, chances are his error levels are lower than yours and it is indeed throwing an error. It is just hidden. Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/#findComment-811129 Share on other sites More sharing options...
PFMaBiSmAd Posted April 16, 2009 Share Posted April 16, 2009 Edit: Basically the same as above ^^^ The public keyword only has meaning inside of a php5 class definition and will generate an error in php4 and when not used inside of a class. We would need to see the full code to provide any help? Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/#findComment-811130 Share on other sites More sharing options...
MasterACE14 Posted April 16, 2009 Share Posted April 16, 2009 or just remove... <?php public $content; if it isn't in a class. Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/#findComment-811156 Share on other sites More sharing options...
Trek15 Posted April 16, 2009 Author Share Posted April 16, 2009 Wow, thanks guys! Uh, perhaps i should have mentioned that that is the first piece of PHP code that i have ever written and i have no idea what you're talking about? lol. Um, anyways, the code has to do with the SSI.php file of an SMF 2.0 RC1 installation. I'm trying to make it so that a page with regular HTML in it gets aware of when users are logged in to the forum in a folder below it. Is anyone familiar with the SSI in SMF? The guy who helped me with this tells me to check for typos in the code and isn't of much help with the actual error. So you say i should make a class out of it? Uh, is that hard to do? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/#findComment-811717 Share on other sites More sharing options...
Trek15 Posted April 16, 2009 Author Share Posted April 16, 2009 For you who asked about the rest of the code, this is the only other code he mentioned me to use, to add to the SSI.php file which the document containing the code in my first post links to at the top of it: // Just return the user name function ssi_getuser() { global $context; if ($context['user']['is_guest']) return "Guest"; else return $context['user']['name']; } // Is the user logged in? function ssi_getlogin() { global $context; if ($context['user']['is_guest']) return false; else return true; } Quote Link to comment https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/#findComment-811893 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.