Solved

LAMP setup for PHP code

Posted on 2014-11-28
6
115 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
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 82

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 61

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 82

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now