Jump to content

Recommended Posts

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>';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/154286-whats-wrong-with-this-code/
Share on other sites

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.

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?

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!

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;

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.