[nycphp-talk] PHP on Win.: Get Drive Letter for Current Script
Dan Cech
dcech at phpwerx.net
Sun Mar 13 12:29:02 EST 2005
Jay,
You should be able to use the getcwd() function to tell you where the
script is running.
Dan
Jayesh Sheth wrote:
> Hi Tim,
>
> thanks for your reply. You referred me to the current Windows API
> function, but my sample (PHP) code did not work.
>
> I think is because this extension only worked with a range of older
> versions of PHP, judging from information on the individual function pages
> for this extension (
> http://us4.php.net/manual/en/function.w32api-deftype.php ).
>
> Here the sample code that I used with PHP 4.3.10
>
> <?php
> // Get current directory using Windows System DLL API
>
> // Load the w32api extension
> // Dynamic loading did not work for me (so I added an entry to php.ini)
> dl("php_w32api.dll");
>
> // Register Windows API function
> w32api_register_function("kernel32.dll", "GetCurrentDirectoryA", "string");
>
> // Make a buffer of appropriate size to store the current directory path
> $buf = str_repeat(' ', 255);
>
> // Call the function so that it stores the value of the current directory
> path in $buf
> GetCurrentDirectoryA($buf, strlen($buf));
>
> // Output it:
> echo "Current directory is $buf .";
>
> ?>
>
> This is resulted in a fatal error saying that GetCurrentDirectoryA is not
> defined as a function. I.e., this extension is not working.
>
> I tried the ffi ( http://pecl.php.net/package/ffi ) extension PHP 5, but
> it gave the following error:
> ---------------------------
> Warning
> ---------------------------
> PHP Startup: Ĥ8: Unable to initialize module
> Module compiled with module API=20020429, debug=0, thread-safety=1
> PHP compiled with module API=20041030, debug=0, thread-safety=1
> These options need to match
>
> If anyone knows a way around please let me know (perhaps a C extension for
> PHP 4? I can understand a bit of C when I read it, but writing it is
> another thing).
>
> Thanks,
>
> - Jay Sheth
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org
More information about the talk
mailing list