php not interpretated

Hi everybody.

I never have had any problem while setting Apache with PHP under Suse. Only recently with 10.3 and 11.0 I have a strange issue. Everything seems fine, php lib is correctly loaded by Apache, but when I try to open a page, php code is visible in the “View/Page Source” of Firefox and not executed.

I’m not able to find the reason. Any idea?

Thanks
Filippo

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Check your Apache log files (/var/log/apache2 probably holds them).
Make sure Apache is also configured so that ‘*.php’ files are
interpreted by PHP and not just sent out directly. Of course I assume
your file ends in ‘.php’. There is also, I believe, a command you can
issue to show Apache’s loaded modules, but I can’t remember it right
now. You mentioned you believe it is loaded… what leads you to
believe that?

Good luck.

aerocom wrote:
> Hi everybody.
>
> I never have had any problem while setting Apache with PHP under Suse.
> Only recently with 10.3 and 11.0 I have a strange issue. Everything
> seems fine, php lib is correctly loaded by Apache, but when I try to
> open a page, php code is visible in the “View/Page Source” of Firefox
> and not executed.
>
> I’m not able to find the reason. Any idea?
>
> Thanks
> Filippo
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI4SeV3s42bA80+9kRAsVKAJ4oEVKGtYKMVRetJR9cBC+uu/CfIQCfUVwg
T+Q4+fvEeCFgymyat4UYg3k=
=m5o/
-----END PGP SIGNATURE-----

One reason is because Apache has not been configurated with the php5 module. You can check what modules are installated with:

/usr/sbin/a2enmod - l

See that php5 is in there. If not:

/usr/sbin/a2enmod php5

as root, of course, then restart apache.

Another reason is you are using short tags <? ?>. You should be using <?php ?> now.

Right. The problem was in short tags. Setting On to short_open_tag in php.ini it works.

I guess that some version ago this switch was On as default, actually it is Off. Any reason why the programmers are pushing to use <?php ?> now?

I checked the loaded modules through Yast/http server.

Thanks to all.

Three reasons are suggested in Coding Rules - ClaroDevel

  • Compatibility with xml files (xhtml, rss, …) where <?xml is used
  • Compatibility with 100% of php server where “short_open_tags” is off
  • “short_open_tags on” will be deprecated in PHP 6

Might as well get used to it.