homepage Welcome to WebmasterWorld Guest from 54.211.95.201
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
unset command causing parse errors
cgallent




msg:1312693
 5:08 am on Jan 16, 2004 (gmt 0)

Everytime I run a php page with an unset command my server is generating a parse error. Is there something in either the php.ini or an .htaccess file that I need to turn on/off or initialize?

Thanks,
cgallent

 

coopster




msg:1312694
 2:56 pm on Jan 16, 2004 (gmt 0)

What are you trying to unset? Or more importantly, how are you using unset() [php.net]?

Note that in PHP 3, unset() will always return TRUE (actually, the integer value 1). In PHP 4, however, unset() is no longer a true function: it is now a statement. As such no value is returned, and attempting to take the value of unset() results in a parse error.

The User Contributed notes also makes a good statement:

As of PHP version 4.3.3, unset() results in a parse error if it is used with the @ error suppression operator.

For example:

@unset($var); // parse error
unset(@$var); // parse error
unset($var); // okay

This is because the @-operator works only on expressions [php.net]. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. (Error Control Operators [php.net])

cgallent




msg:1312695
 3:22 pm on Jan 16, 2004 (gmt 0)

I'm not trying to unset anything. What is happening is that I have two php applications that I've installed - one widely used BB. I have them installed on other servers and they work absolutely flawless.

I just setup my own VPS and have uploaded these and in each case the only error that I'm getting is the parse error on the unset command.

My thought is that it's something in the php.ini that's turned off/on or not set properly.

coopster




msg:1312696
 4:15 pm on Jan 16, 2004 (gmt 0)

>>I'm not trying to unset anything.

I'm referring to the unset [php.net] statement in PHP. This is what seems to be giving you the parse error.

What version of PHP are each of the servers running? PHP 3 treated unset as a function and as of PHP Version > 4, unset is a statement. This may be your issue. Read my last post carefully now that you understand what I mean by unset. Sorry for the confusion.

If possible, find the line giving the error and post it for us to take a look at. Also, the version of PHP on the server is important regarding how the statement is being used.

cgallent




msg:1312697
 4:58 pm on Jan 16, 2004 (gmt 0)

Here's one:

unset($block_names[$block_nesting_level]);

I've looked at the others and they're all written the same.

Server:
Apache 1.3.29
PHP 4.3.3

Ideas?

coopster




msg:1312698
 5:26 pm on Jan 16, 2004 (gmt 0)

Well the syntax looks fine for PHP 4.3.3.

Are you sure that unset is the actual problem? Parse errors [php.net] can be tough to find sometimes. They usually occur when you are missing a closing semicolon or brace. Can you post the exact error message you are getting?

cgallent




msg:1312699
 6:24 pm on Jan 16, 2004 (gmt 0)

Parse error: parse error in /home/musiccit/public_html/members/bb/includes/template.php on line 356

That's the line that I've included.

Thanks for the help to date - I really appreciate it.

BitBanger




msg:1312700
 7:22 pm on Jan 16, 2004 (gmt 0)

Could it be a missing semicolon on the preceding line?

coopster




msg:1312701
 7:57 pm on Jan 16, 2004 (gmt 0)

I don't think this has anything to do with
unset. The reason I make this statement was a quick search on google for phpbb "template.php on line 356" and you'll see what I mean.

I'm guessing that either your template.php file has been modified or changed or else the $code variable that is being passed to the compile function within that script is the issue. If all you did was transfer the same template.php from one server to your new server, I'd double check that $code variable and how it is being processed within the compile function step by step until you nail down what is causing the problem. There is a developer note in there stating that some funky things might happen if you have a #<!-- BEGIN (.*?) --># and an #<!-- END (.*?) --># on the same line.

cgallent




msg:1312702
 9:27 pm on Jan 16, 2004 (gmt 0)

I got it fixed. I had to upgrade to php v4.3.4 and that took care of it.

Thanks a ton for the input.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved