Jump to content


Photo

PHP Version Question


Best Answer kicken, 19 August 2014 - 11:21 PM

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. Go to the full post


  • Please log in to reply
7 replies to this topic

#1 xFalseProphet

xFalseProphet

    Newbie

  • New Members
  • Pip
  • 7 posts

Posted 19 August 2014 - 09:06 PM

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!



#2 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,236 posts
  • LocationWA

Posted 19 August 2014 - 09:09 PM

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.

#3 xFalseProphet

xFalseProphet

    Newbie

  • New Members
  • Pip
  • 7 posts

Posted 19 August 2014 - 09:24 PM

Its really frustrating lol. I have tried to do phpinfo() on the server his website is on but its been disabled. I dont think i have used any php 5.5 features that im aware of, but i may be wrong. 



#4 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,615 posts

Posted 19 August 2014 - 09:28 PM

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.

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 


#5 xFalseProphet

xFalseProphet

    Newbie

  • New Members
  • Pip
  • 7 posts

Posted 19 August 2014 - 09:36 PM

I cant post the code here, its a full script. It has around 60 files each with at least 900 lines of code in each lol. I will try running display errors and see what happens.



#6 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,731 posts
  • LocationBonita, FL

Posted 19 August 2014 - 11:21 PM   Best Answer

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#7 xFalseProphet

xFalseProphet

    Newbie

  • New Members
  • Pip
  • 7 posts

Posted 20 August 2014 - 10:26 AM

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. 



#8 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,615 posts

Posted 20 August 2014 - 10:52 AM

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.

multi-purpose programming fool. well written source-code should be self-documenting. well written code should be self-troubleshooting. 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com