For example, development is carried out under Windows, and the finished project is rotated on a Linux server. Here are a couple of potentially problematic issues I encountered:

  1. When developing under the form of PHP loyally refers to the omitted quotes in the indication of the array key: $foo[bar] . But Linux swears and refuses to work without quotes: $foo['bar'] . Therefore it is better not to drop quotes.
  2. In PHP 5.3.0, the magic constant __DIR__ , but it is likely that an older version of PHP is still running on the hosting, so it is better to use dirname(__FILE__) .

Share your findings?

    1 answer 1

    About PHP problems on Habré quite a lot and is described in detail.

    • Excellent answer ^ _ ^ $ a = 'aaa'; $ b = 0; var_dump ($ a == true && $ b == false && $ a == $ b); - Zowie
    • @AlexWindHope, wait a minute. In the case of casting a string to a boolean value, True is obtained (compared — everything is ok), and in the case of reduction to a number — 0 (again, two zeroes were compared — everything is ok). - Denis Khvorostin
    • @Khvorostin if you consider this behavior normal, then, of course, you will not have any problems with PHP. By the way - why would it not lead to an empty line to 0? (This is a stone in a PHP garden) Well, it doesn't matter, the main thing is that this behavior is obvious to you. Just, as for me, it looks absolutely crazy: $ str = 'some string'; if ($ str && $ str! = 0) {// false} Maybe someone even likes this, but not me - Zowie
    • one
      @Khvorostin, one thing I know for sure, not an empty line == 0 is complete nonsense. If we talk about comparing strings with numbers, I like how it is implemented in "JS like" languages, but all this is possible thanks to NaN: // so that it is clear NaN> 0 // false NaN <0 // false NaN == 0 / / false Number ('str') // NaN Number ('\ t \ n \ n \ t \ t') // 0 '\ t \ n' == 0 // true '\ t \ na' == 0 // false 'str' == 0 // false 'str'> 0 // false 'str' <0 // false - Zowie
    • one
      In general, this kind of problem is solved by widespread use === instead of == , but, unfortunately, it is not often practiced and certainly not everywhere and not always - Zowie