Jump to content

PHP Wont Parse


StormTheGates

Recommended Posts

Hey all, I have an odd problem that I hope someone here has had and knows how to fix.

 

I recently installed Apache, PHP, and MySQL on a new server we have at work. Everything works fine, oddly enough, except for PHP parsing.

 

You see the following code:

 

<?
echo "test";
?>

 

Will display the PHP code, while

 

<?php
echo "test";
?>

 

Will echo "test". The problem seems to be that PHP isnt parsing the <? directive as a start command. Does anyone have any idea why this might be?

 

Thanks for any help.

Link to comment
Share on other sites

Don't use the short open tags. It results in non-portable code because you won't always be on a server where you will have the ability to turn the setting on.

 

You have probably already wasted 10x times more time messing with this on one server setup than you ever saved in typing time by leaving off three letters a few times on a page.

 

If you simply use full opening tags, you won't ever need to waste any of your time messing with this problem when you put your code onto a different server. And if you ever expect to publish any of your code for others to use, you CANNOT use short open tags in it because the people using that code won't necessarily have the ability to turn on the setting on their server.

Link to comment
Share on other sites

Don't use the short open tags. It results in non-portable code because you won't always be on a server where you will have the ability to turn the setting on.

 

You have probably already wasted 10x times more time messing with this on one server setup than you ever saved in typing time by leaving off three letters a few times on a page.

 

If you simply use full opening tags, you won't ever need to waste any of your time messing with this problem when you put your code onto a different server. And if you ever expect to publish any of your code for others to use, you CANNOT use short open tags in it because the people using that code won't necessarily have the ability to turn on the setting on their server.

 

Relax boss, I didnt exactly get a choice. The government hands me the code, I just make it run on our servers.

Link to comment
Share on other sites

Ummm. You can search and replace the tags to fix the problem forever in any piece of code.

 

You assume that the government wants things functional and backwards compatible. The last time I mucked with their code they had a hissy fit. Trust me I know <? are bad tags, Ive seen benchmarks where the <?php is much faster. But sadly they are paying the bills so I just make our server run it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.