birbal Posted March 7, 2011 Share Posted March 7, 2011 how can i make a script platform indipendent? i am geting frustrated to fix the scirpts when i move on the scripts to different platform(eg linux-win vice versa).(i was using linux before)it is wireing now and i am getting confused with different notations. please clarify from the basics for windows and linux separately.thank you Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2011 Share Posted March 7, 2011 The simple answer is not to use anything that is platform-dependent. If you're looking for a list of those things, it's a long list. Many extensions and functions depend on OS commands to do certain things, so they only work on certain OSs. Here's an example, on Windows servers this function only works on certain versions:http://www.php.net/manual/en/function.symlink.phpFor other things, PHP defines constants to represent operating system values. Don't hard-code a backslash in a directory path, for example, when you should be using the DIRECTORY_SEPARATOR constant, which contains the OS-defined directory separator.PHP options are something else to consider. Don't rely on things like short tags or magic quotes when they may be enabled or disabled on various servers. When possible, detect what the environment is and respond appropriately. If magic quotes is on, for example, then you need to use stripslashes when you get data from $_GET, $_POST, or $_COOKIE. Otherwise, you don't. The basic rule is to check settings in the script instead of assuming you know what they are. Link to comment Share on other sites More sharing options...
birbal Posted March 7, 2011 Author Share Posted March 7, 2011 yes thats what i was looking for. i was expecting there is a good manner to do it. If you're looking for a list of those things, it's a long list.and can you give any link of those list which i can take a look.and what about ../ and / is it react different from linux and windows? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2011 Share Posted March 7, 2011 I don't know if anyone has made a list. A search might help:http://www.google.com/search?client=opera&...channel=suggest and what about ../ and / is it react different from linux and windows?Both systems use two dots to indicate the parent directory, but the separators are different. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 7, 2011 Share Posted March 7, 2011 There's a list here about which elements in $_SERVER get populated by various servers also:http://koivi.com/apache-iis-php-server-array.php Link to comment Share on other sites More sharing options...
birbal Posted March 8, 2011 Author Share Posted March 8, 2011 ...thanks for the help again. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.