Jump to content

PHP 4 vs. PHP 5


Recommended Posts

Hello all,

Issue #1)
I recently switched from a shared hosting plan to a dedicated server. When I switched I switched from php 4 to php 5. All of my scripts seem to run fine, with minimal differences. However, before, if I made a parse error, the error would display on the page, UNEXPECTED ... PARSE ERROR.  Now this no longer happens. If there is a parse error, the page will simply not display. I would like to get the old errors back. Another issue...

Issue #2) My website takes up about 30 gig including everything. I have about 150 gig of server space which recently filled up completely becasue my error_log file got to about 120GB. The error log contains millions of php errors such as undefined var errors which don't stop the scripts from running, just report stupid errors. One example of these errors is an undefined var in an if statement. here is a sample of the code.

page.php?
[code]if ($_GET['some_var'] == '')
//do something[/code]

Well, this creates an error if the some_var variable is not set within the URL. But this is stupid because it works correctly, because if it is not set it is also the empty string '', so it performs as I want it to despite accumulating a 120GB file on my server.  Is there anything I can do about that? Is that in any way related to php 4 vs. php 5.

Issue #3)My scripts, including some that were written in open source by professionals, send out emails automatically (for example to register to a forum). These emails no longer get sent. Is this possibly related to the difference in php versions. Maybe its a firewall thing?

Any help at addressing any one of these issues is appreciated.
Link to comment
Share on other sites

For issue #1 you need to turn your error_reporting level up to E_ALL and turn display_errors on

For issue #2 it is not a stupid error. It actually an error on your part, your syntax is slightly wrong basically. With the following code:
[code]if ($_GET['some_var'] == '')[/code]
You are checking the $_GET['some_var'] variables value and not the existence . However if this variable does not exist then PHP will report an undefined variable/index notice (not an error). What you should do is first check for the existence of the variable and then check the value of the variable if it exists. So you'll do something like this:
[code]if(isset($_GET['some_var']) && $_GET['some_var'] == '')[/code]
Now when you run your script. PHP will now check for the existance of the $_GET['some_var'] variable first, then if it finds the variable it will now check the value of the variable. Whereas before you are not checking the existence of the variable and so PHP thinks this variable already exists and thus you get the undefined notice message.

If(isset($var)) and if($var) are two completely different things, they are similar but they have different behaviour.

For issue #3 you may need to configure PHP to use your server SMTP Server.
Link to comment
Share on other sites

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.