I recently set up an AWS EC2 instance and installed Apache, PHP, and MySQL on the 64-bit Linux server using yum
Then I uploaded my php files for my contact form in /var/HTML/WWW
It displays fine except parts of my contact form are being displayed. They are PHP— the PHP tags and the code within them are being shown.
Here is a live example: 23.23.152.36
And here is a version on another server where its working fine.
Does anyone have any ideas why this is happening?
Do you have PHP enabled on your webserver? For Apache, you may need to modify httpd.conf to enable PHP.
Can you run phpmyinfo() on your webserver?
Enable short_open_tag in you php.ini
short_open_tag
Default Value: On
Development Value: Off
Production Value: Off
shorthand notation is on its way to deprication, i wouldnt suggest building code with shorthand notation anymore.
just use <?php echo ?>
You want to change <?php=$name;?> to <?= $name ?>. That's what you need to do if you want to use the shorthand notation.
Related
I have some PHP files developed on a Linux machine, which I am now working on on a Mac (OS 10.8.2). Pages were not showing up correctly on the Mac, even when they were showing correctly on the linux box. After some investigation, I found that it was because it wasn't recognizing syntax like this:
<?=$var ?>
Anything starting with just a <?, rather than a <?php (not just the var shortcut above, any block of code) is being interpreted as plain text, rather than PHP. On the Linux dev box and production server, the shortcut <? syntax is recognized just fine. I assume this is a configuration thing that I missed during setup, so what did I miss? Can I configure my Mac to recognize this syntax?
The mac is running PHP 5.3.15. The dev box is running an earlier 5.*. I don't know the version on the production server.
Either upgrade to PHP 5.4 (which supports <?= .. ?> all the time), or enable the "short tags" setting in the php.ini file.
These are called short tags.
Edit your php.ini file and set:
short_open_tag=On
I am trying to create my first dynamic site on windows server 2008 r2. I have created other dynamic sites successfully on linux based systems but I am having a little bit of trouble with this.
So i have php, mysql and phpmyadmin installed on the server.
I have a page (index.php) with the following:
<?php
include 'php/index.php';
mysql_set_charset('utf8');
?>
This works fine and does not show when i do 'view source' on the displayed page in a web browser.
Further down my page i have the following:
<?=$obj->get_email()?>
This statement is to be used to pull information from a database. When i do view source it shows the get_email() command as seen above. Instead of what it should be replaced with .
Is this a PHP issue? Is this type of command not suitable with windows server or am i just doing something completely stupid??
Try it without short tags:
<?php echo $obj->get_email(); ?>
You should check php.ini for the setting: short_open_tag and change it to 1 if you wish to be able to use <? to jump into PHP mode.
Barring that, just changing it to <?php echo $obj->get_email(); ?> will fix your problem.
Reference
I am using wamp server 2.0 on windows XP with PHP version 5.2.5 when I am using the following code
<?
echo "hai";
?>
I am not getting the output. But when I am using
<?php
echo "hai";
?>
Got the result.If I am using the first one in Linux server I got the output.One of my large project like the first one in all php pages.I want to configure with wamp.SO if first coding needs to work what can I do?
My first guess is your php.ini isn't configured for this. The parameter short_open_tag is responsible for it.
Edit your php.ini, search the following parameter and activate it (or add it when its missing there):
short_open_tag = On
More details are in the php-manual.
i'm not using wamp now, maybe you can test solution from http://www.wampserver.com/phorum/read.php?2,50473,50474#msg-50474.
Wish this can help you. :)
I have a php-file which includes another html-file:
<? virtual("../top.html");?>
The problem is that any code before this include compiles and runs well, after - nothing. There aren't any errors etc. After commenting this line, everything works.
Code was written under local computer with ArchLinux + LAMP. Now I have ubuntu 10.04 with the same configuration.
What could it be?
You might try changing top.html to top.phtml and using require_once.
<?php require_once('../top.phtml'); ?>
If you just want to pass some html from a file into your output, you could also use:
<?php echo file_get_contents('../top.html'); ?>
That way, you stay independent of the underlying webserver and you make sure, that no php code that may be in the html is being executed.
However if you wish something in there to be executed, you can use require_once() as stated by Jeremy.
Can you check error log of the Apache?
Also, you should use
<?php virtual("../top.html");?>
if your php.ini has short_open_tag = Off.
i have one complete website
which was written in php4, now my hosting server is PHP Version 5.3.2, windows 2008 server
and my site is not working, what i found is old site use following syntax
<?
but if i change it into
<?php
page start working. is there any way to solve this issue...
PHP Version 5.3.2 work with
<?
any script which change all
<? to <?php
in all pages.
This is not down to the PHP version, but depends on the short_open_tag php.ini setting.
You can change the ini setting to "1", but the use of short open tags is generally discouraged these days.
Short tags are a discouraged feature of PHP. You should convert all <? to <?php, because as of PHP 6.0, they will be deprecated. (This is partially to better support XML documents, which have a tag that starts with <?)
BTW, you can turn them on in your configuration.
the following code snippet helped me convert all short tags to proper PHP tags, hope it helps you too:
REPLACING SHORT TAGS WITH PROPER PHP TAGS (archived copy)
There is a directive in your php.ini file called "short_open_tag". This is what allows you to use the shorthand or not. They should not be used anymore though, so its better if you update all tags to the new format.
Metropolis