Jump to content

PHP Version Question


Go to solution Solved by kicken,

Recommended Posts

This may sound like a really stupid question, but this is really bugging me.

 

If i code something in PHP 5.5.11 and upload it to a server that is running PHP 5.4, would the code work correctly? I didnt think there was a super amount of difference between the two versions. Perhaps im wrong.

 

The reason i asked is because someone has given me a project to help them with. Im running php 5.5.11. I coded it, tested in in xampp, working great. I upload it to his website, which he told me is currently running 5.4 (i tried phpinfo() but they have disabled it) and a majority of the functions i coded are no longer working. Things are not writing to the database, things collected from the database either dont show up on the website or they only show up when something gets posted after it, in which case the something posted after it doesnt show e.c.t.

 

Is the difference that much it can break code?

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/290548-php-version-question/
Share on other sites

If you used any PHP 5.5 features then you'd probably be aware of it.

 

More likely is a difference in the configuration between your environment and his. php.ini settings, extensions enabled, database credentials, that kind of thing. Ideally you would be testing your code in an environment that is as close to the real thing as possible - working in XAMPP and deploying to IIS (for example) is just asking for problems.

 

Do a phpinfo() on both setups and see what the differences are.

things which are configuration dependent (and php version dependent) will be producing either php syntax or runtime errors. if the pages all actually run at all, then at least the main pages don't contain php syntax errors and you can set php's error_reporting to E_ALL and display_errors to ON in the code to see what errors are being detected by php.

 

you could also post the code here and someone could directly tell you the most likely things it is doing that would be configuration or version dependent.

  • Solution

Migrating from PHP 5.4.x to PHP 5.5.x

 

That covers things to be aware of regarding differences between the two. Look through it and see if you have used any of the new features.

 

If phpinfo() is disabled, using ini_get_all may work as a way to check INI directives. You could also use extension_loaded or function_exists to test if various extensions or functions that you need are enabled.

Thank you very much. I checked out your link and nothing there affects my code which made me think it was an sql error. Took a look at my code and it turned out i had missed a comma on one line, and 2 ' on another. I hate missing things like that. 

your testing on the development system should have found things like query errors. your code should also have logic that tests each query to see if it failed or not and take an appropriate action. if a query does fail, you should output a user message - 'Sorry, an error has prevented this page from completing the requested operation' and log the actual query and the database error message.

 

testing is more than just checking that the code runs. it means testing if the code does what you expect for both expected values and unexpected values and making sure that the code produces the expected result for all the possible execution paths/logic branches.

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.