Solved

LAMP setup for PHP code

Posted on 2014-11-28
6
127 Views
Last Modified: 2014-12-01
I have a centos 6 LAMP setup.

In page1.php
<html>
 <head>
  <title>Page 1</title>
 </head>
 <body>
 <?php echo '<p>Hello World</p>'; ?>
 </body>
</html>

in page2.php
<html>
 <head>
  <title>Page 2</title>
 </head>
 <body>
 <? echo '<p>Hello World</p>'; ?>
 </body>
</html>


Page1.php will load and page2.php will not.  If I change the <? to <?php then the page loads correct.
I have been told that there is a change I can make on a .ini file that will tell the server to handle all <? as PHP code.
Where is that at?
0
Comment
Question by:knightdogs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Accepted Solution

by:
10023 earned 400 total points
ID: 40471229
This is what i have in my wamp php .ini file
open in notepad from wamp button and use find:
; short_open_tag
;   Default Value: On
;   Development Value: Off
;   Production Value: Off
0
 
LVL 10

Expert Comment

by:10023
ID: 40471231
Centos
/etc/php.ini
Don't forget to restart server
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40471270
I recommend that you do Not make that change and learn to use <?php as the opening tag all the time.  It always works but some servers have the short open tag <? turned off which will cause your code to fail as you have seen.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 62

Expert Comment

by:gheist
ID: 40471896
correct way is to use ?php
because you can have multiple SSI languages, like mod_include, ruby passenger, jsp, you name it.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40471935
The reason to have the short open tag <? turned off is that it is also the opening tag for XML.  Using <?php avoids any confusion.
0
 

Author Closing Comment

by:knightdogs
ID: 40473612
10023- Thank you for your answer.  It fixed the issue

Dave Baldwin- Thank you.  I will have the coder fix that.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question