Jump to content

Recommended Posts

I am a freelancer, I design my own custom scripts and mods.

 

The major problem with my script is they run alright on my local server (XAMPP) but when I deploy them on my clients server (more then 20-30), they sometime break because I dont know what is exactly required by my script.

 

Then I do poor man's debugging to track the error.

 

Can please someone tell how can I find what are basic requirements of my script ?

 

Should i use function_exists() method to find if everything is present on production server ?

 

Any more ideas folks ?

Link to comment
https://forums.phpfreaks.com/topic/210925-requirements-of-a-script/
Share on other sites

Most (I say most) servers should be running PHP5 at least. When coding an application, you should take note of some of the more newer functions you use and the available versions they are on. If you are making an application that you want to run on many different environments and need to make use of a function available on a PHP version that is fairly new, then you should make use of function_exists() so that you can re-create that function.

What you're dealing with is portability. There are many techniques that you can use to ensure that you code is portable and works on all systems that you'll be deploying it on.

 

Some things are very simple rules of thumb, and others are more complicated. One example of a simple rule you should always follow is never use short tags (<? ?>). Using the full tags (<?php ?>) ensures that you code will still work on PHP installs that have short tags disabled.

 

As new versions are released they offer new optimizations, features, changes etc.. You can use phpversion to check the version of PHP, or a more specific extension, that is being run. From this you can decide what your code will do; For example, if you decide that you want to make your code PHP 4 compatible and you're using OOP you'll have to write an alternative solution that doesn't use the OOP features that weren't introduced until PHP 5 (e.g. the public/private/protected visibility keywords).

 

While you're writing your code you should make sure that the functions you're using all available in the versions of PHP that you hope to support; the PHP manual does a great job of telling you this. If they're not you need to make sure to provide an alternative solution that will be supported.

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.