Forum Moderators: coopster

Message Too Old, No Replies

Linux PHP

         

hexdj

4:35 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



My hosting provider says in their page they only support PHP for Linux, what does that mean?
If I upload files that I made in a windows pc they won't work or what?
isn't PHP supposed to be cross platform?

jatar_k

4:37 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I figure they are not explaining it very well

>> PHP for Linux

should probably be

PHP on Linux

and yes it works cross platform

hexdj

5:10 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



How is it different though? Does that affect me in any way?

gliff

5:44 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



The biggest differences will be related to the file system.

For example, windows will let you specify a path with backslashes.

$path = 'path\to\file';
$path = "path\\to\\file";

Linux/Unix expects forward slashes

$path = '/path/to/file';

PHP is "smart" enough to let you use the forward slashes for paths, even when developing on Windows, so unless you have a compelling reason otherwise you should use the forward slashes.

File permissions are another big difference. If you're writing to files you'll need to account for Unix style file permissions on the server, which is something that won't affect you on Windows.

There are lots of other little differences which may hinder you. In general, the PHP manual is pretty good about mentioning little differences in the function definitions (for example, flock [us3.php.net]). Your best bet is deploy/test often to the Linux server. Once you start to learn the little differences you'll know to code around them in the future.

dhardisty

6:55 pm on Aug 15, 2005 (gmt 0)

10+ Year Member



another difference is line endings.

windows uses \r\n, while linux uses \n. So depending on your ftp settings and what program you use to edit your php files, files you download from your server may come out with no line breaks.