I think I've done what's necessary to install mod_php in Apache, but this code fails:

----------modtest.php
<?php echo $PHP_SELF?>
------------------------

When I display modtest.php in a browser, I get:

Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache Group\Apache2\htdocs\modtest.php on line 1

I've read in docs that this env var doesn't exist in the comand line version, which I've verified is working because displaying this page is successful:

-------------printinfol.php
<?php echo 'This is my first PHP web page.' ?>
-------------------------

I have this line in my http.conf file:

LoadModule php5_module "c:/php/php5apache2.dll"

and verified that file exists in that directory. Did I miss something to get mod_php to work?

Using Apach2 in WinXP Home with php5.

Thanks in advance!

Thanks Roberdin, you rock!

BTW, the "out-of-date source" is a university professor, and this is par for his course. :(

Just so I'm clear, is PHP_SELF deprecated for all versions of PHP or just windows versions?

I did a quick google search and came up with this off of phpfreaks.com: $PHP_SELF should not be used because it will not work without register_globals being enabled. Rather, you should use $_SERVER for it.

I think I've done what's necessary to install mod_php in Apache, but this code fails:

----------modtest.php
<?php echo $PHP_SELF?>
------------------------

When I display modtest.php in a browser, I get:

Notice: Undefined variable: PHP_SELF in C:\Program Files\Apache Group\Apache2\htdocs\modtest.php on line 1

I've read in docs that this env var doesn't exist in the comand line version, which I've verified is working because displaying this page is successful:

-------------printinfol.php
<?php echo 'This is my first PHP web page.' ?>
-------------------------

I have this line in my http.conf file:

LoadModule php5_module "c:/php/php5apache2.dll"

and verified that file exists in that directory. Did I miss something to get mod_php to work?

Using Apach2 in WinXP Home with php5.

Thanks in advance!

Method 1// try to close error message from php in php.ini
Method 2// try to use $_SERVER instead of $PHP_SELF

This article has been dead for over six months. Start a new discussion instead.