Solved

LAMP setup for PHP code

Posted on 2014-11-28
6
131 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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