# test.php with <? phpinfo(); ?> not working in a browser



## zzatskl (Sep 13, 2011)

I am trying to create a backup server and have done a clean install of FreeBSD 8.2 with Apache 2.20.0 and PHP 5.3.8. Apache seemed to install OK (I got the usual 'It Works' message), but I can't run test.php with the code in this post title. I compiled php5 with APACHE=true. If I enter this from the command line:

```
[cmd=%]php -r 'print_r(phpinfo());'[/cmd]
```
I get the php info results one would expect. But from a browser I only either get the text entered in test.php or a WSOD (depending on what I tried to solve the problem). The httpd-access.log after entering test.php in the browser shows: 

```
192.168.0.2 - - [12/Sep/2011:23:49:45 +0100] "GET /test.php HTTP/1.1" 200 17 "-" "Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2"
```
Note the httpd server is running on 192.168.0.3 the browser call was from 192.168.0.2. I have been seeing these errors in the httpd-errors.log:

```
[Mon Sep 12 23:22:08 2011] [warn] (22)Invalid argument: Failed to enable the 'httpready' Accept Filter
```
and

```
[Mon Sep 12 21:52:12 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
```
But I'm not sure they're relevant. There appearance depends on whether I use stop, start or restart with the apachectl command. I have only added these lines to httpd.conf:

```
DirectoryIndex index.php index.html index.htm
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .htm .html
```
And DocumentRoot has allow from all permission. Please can somebody offer some guidance. As my mother would say:


> I can't see for looking


----------



## Anonymous (Sep 13, 2011)

zzatskl said:
			
		

> test.php with <? phpinfo(); ?> not working



Only a wild guess.

Did you already check the value of "short_open_tag" in the file /usr/local/etc/php.ini? The default value is "On". If by any chance this has been set to "Off", then, as matter of fact, <? phpinfo(); ?> would not work, and you would need to rewrite this to <?PHP phpinfo(); ?>.


----------



## zzatskl (Sep 13, 2011)

Thanks, that works. However I notice in /usr/local/etc there are nowadays two sample files to copy to make a php.ini one 'development' and one 'production', in both 

```
php -r 'print_r(phpinfo());' | grep 'short_open_tag'
[color="DarkGreen"]short_open_tag => Off => Off[/color]
```
However, after careful reading in both ini versions I notice the lines:


> ; <? and ?> tags as PHP source which should be processed as such. It's been
> ; recommended for several years that you not use the short tag "short cut" and
> ; instead to use the full <?php and ?> tag combination. With the wide spread use
> ; of XML and use of these tags by other languages, the server can become easily
> ...


So it just goes to show that you should 'read the manual' and not rely on code that works on a machine from an earlier installation. However, I do find the instruction a little confusing, shouldn't it read:


> Default Value: Off


Perhaps this is one for the port maintainer?
As my father used to say:


> If I don't see you through the week, I'll see your through the window


Thanks again for a simple but very helpful tip.


----------

