I am coding in a Windows platform, then I hosted it in a Linux platform, then some codes did not work as it should be. So I am curious if this is normal or I just have an error on my part. Both PHP versions on Windows and Linux are PHP 7.1.1.

  • 2
    PHP code should work the same. OS case sensitivity and paths are all that really separates one PHP install from another. I routinely code in PHP on a Mac, collaborated with users on Windows, deploy to many different version of Linux without issue. Jun 10 '17 at 2:22
  • Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.
    – DavidPostill
    Jun 10 '17 at 13:49

They will not all work the same. As PHP has matured it's deprecated features and added new ones. Simple code, and code designed for maximum compatibility should run on a range of versions - sometimes all versions, but it is very common to come across functions which require a minimum version - somewhat less common to find functions that don't work in newer versions (but often require supressing debug messages and/or yweeking configs to make it work)

  • thanks, what if something like this php 7.1.1 Linux, php 7.1.1 Windows, will that work the same? Jun 10 '17 at 5:13
  • This is a ridiculous answer. The question is very clearly not about someone running PHP 4 code under PHP 7 but rather moving their PHP code from one platform or another. Jun 10 '17 at 12:57
  • @Jakegould - I think your heavily modifying the question as per your interpretation and then criticizing my interpretation is not cool.
    – davidgo
    Jun 10 '17 at 19:14
  • @DumbQuestion - if you use the same version of PHP on Windows vs Linux the syntax should be the same and most code should work, but there will be differences due to underlying OS's - relative paths and functions which only exist in 1 version due to OS or library dependencies spring to mind.
    – davidgo
    Jun 10 '17 at 19:17
  • @davidgo “I think your heavily modifying the question” Really? The comment from the original poster above reads, “thanks, what if something like this php 7.1.1 Linux, php 7.1.1 Windows, will that work the same?” Jun 10 '17 at 20:45

I was learning PHP back in my college in Linux environment. Then for my project I used Windows on my home, only to find later that it is unusable on my campus lab.

The problem lies in how Linux treats "everything" as case-sensitive, while Windows quite lenient in what should be case-sensitive.

Fixing the code to consider case-sensitive parameter, class, and function makes my application work again.

  • 1
    case sensitivity is not the only difference between Windows and Linux. There may be system-specific calls in the PHP code that makes it fail
    – phuclv
    Jun 10 '17 at 5:59
  • @LưuVĩnhPhúc What “system specific calls?” By your logic 90% of the Internet should not work because someone is deploying PHP code developed on Windows to a Linux box running PHP. Jun 10 '17 at 12:58
  • @JakeGould if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { do_stupid_things(); }
    – phuclv
    Jun 10 '17 at 13:06
  • @LưuVĩnhPhúc Very few PHP programmers I know actually do what you describe. It‘s a fairly solid edge case and not much else. Jun 10 '17 at 13:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.