Solved

LAMP setup for PHP code

Posted on 2014-11-28
6
122 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 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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