Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find which PHP functions Windows does not support?

Tags:

php

windows

My normal development platform for PHP is Linux. I use a Red hat server for my website, my company uses red hat and Fedora for production, and I have Ubuntu at home. I couldn't be happier. Unfortunately, I'm now required to spend a good deal of time working in PHP in Windows using WAMP.

I say this is unfortunate because I am continually finding things which Linux supports which Windows does not. Last year, it actually delayed a project when we realized that WAMP used an earlier version of PHP (this has been fixed by the port of 5.3 to Windows). Today, I just learned that checkdnsrr is not ported to Windows, and the entire pcntl library is unavailable.

So, my questions is this: Is there anywhere which tells me the current differences between Windows and Linux regarding PHP?

I'm not looking for idiosyncrasies, such as those found in the comments here (though those would be nice), but rather which functions will not be available under Windows which are available under Linux.

----------------------- EDIT -------------------------

There have been two comments/statments which say thatcheckdnsrr exists in 5.3 under Windows. Technically, this is correct. PHP will not say that the function does not exist. I don't know if this is the case with all installs or just WAMP, but while yes, it may say that it works, the function does not work as it does in Linux.

--------------------- UPDATE ----------------------

It does not look like there is a good answer possible to this question, but I have found a workaround thanks to one of the suggestions below:

Place this on the production environment. REMEMBER TO FORCE SOME FORM OF SECURITY ON THIS.

 <?php print_r( get_defined_functions() ); ?>

Then run this on the dev environment. it will output all of the functions which are exclusive to the local environment.

$root = file_get_contents( "<path to server>/available.php" );
$root = preg_replace( "/\[[0-9]{1,4}\]\s=>\s/", ( '' ), $root );
$tmp  = '"internal" => array';
$root = explode( "\n", substr( $root, strpos( $root, $tmp ) + strlen( $tmp ) + 1 ) );
array_shift( $root );
array_shift( $root );
$internal = get_defined_functions();
$internal = $internal[ "internal" ];

function trim_array( array $root )
{
    $nroot = array();
    foreach( $root as $key=>$value )
    {
          $value = trim( $value );
          if( !preg_match( "/^[a-zA-Z_]*[aeiouy]+[a-zA-Z0-9_]*$/", $value ) && 
              !preg_match( "/^[a-zA-Z_]*(md5|crc|n12|str|sqrt|ch[a-z]?r|dl|tnt|ftp|png)[a-zA-Z_]*$/", $value ) )
          {
                //echo "\n $key ";
          }
          else
          {
             $nroot[] = $value;
          }
    }

    return $nroot;
}

$root     = trim_array( $root );
$internal = trim_array( $internal );

$diff = array_values( array_diff( $root, $internal ) );
foreach( $diff as $key => $fname )
{
      if( in_array( $fname, $root ) )
      {
            echo "[$key] => $fname <= foreign server only";
      }
      else
      {
            echo "[$key] => $fname <= local";      
      }
      echo "\n";
}
like image 424
cwallenpoole Avatar asked Jan 28 '10 23:01

cwallenpoole


2 Answers

First, bear in mind that some cross-platform issues are not due to lack of support but the idiosyncrasies you mention, the worst that comes to my mind is the direction of the directory slash. Or the issue is not with the platform but with the server. For instance, Apache has environmental variables that IIS doesn't even though it would seem like things at the HTTP level and TCP/IP level would be OS-neutral.

On that note:

  • pcntl is based on the Unix process model, so it wouldn't have Windows support.
  • checkdnsrr is supported for Windows as of 5.3, and a package existed for adding that extension in Windows before.
  • There is a list on PHP.net of Windows-only extensions (COM being the one that leaps my mind without checking), but my guess is that since PHP was designed originally for Unix (or at least POSIX) and since 85% of the web is on Apache (I made that number up), their isn't as much of an outcry, though you're right that there should be one.

If it was me, I would go crazy and make a script that scraped the entire extension list page and systematically have it check the intro page for "Windows" to get an idea of which ones are either special or not available. But that's me, I'm zany.

Oh,and here's a quick list of libraries that PHP is either developing for Windows or is never going to develop:

http://wiki.php.net/internals/windows/libs

like image 166
Anthony Avatar answered Nov 15 '22 13:11

Anthony


I have no idea if a site like you ask for exists, but you can use these methods to find out about a PHP installation:

  • get_defined_functions() — Array of all defined functions
  • get_loaded_extensions() — Array with the names of all modules compiled and loaded
  • get_extension_funcs() — Array with the names of the functions of a module

It's somewhat difficult to say: this is available on Windows and this isn't on a general basis for often functions depend on the PHP version and this can just as much affect any OS.

like image 25
Gordon Avatar answered Nov 15 '22 13:11

Gordon