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. :)
Related
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.
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'm a PHP developer, and trying Webmatrix lately,
I have successfully install PHP to IIS, and use it, it's pretty neat I say
then, one time i hit this problem
while
<?php echo "Hello World"; ?>
or
<? echo "Hello World"; ?>
works just fine,
but
<?= "Hello World"; ?>
is not working at all, and i thought it was my mistake, then i start apache, and run it from there, and it works..
So, how to get to work?
It work on apache, but not on IIS.. anyone having same problem?
I'm using PHP 5.3.8 + IIS 7.5 Express + Web Matrix
Thanks
Resolved
OK, I have resolve this problem,
The answer is simple and annoying, I'm using Windows 7, the main problem is UAC,
every time i save the php.ini, it's saved to the Virtual Store instead of the original location (because i dont use administrator right when editing)
I tried to edit the php.ini under administrator right, and Boom! worked like a charm!
Thanks for your answer
Check if the short-open-tag is enabled in your php.ini
http://www.php.net/manual/en/ini.core.php#ini.short-open-tag
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 am writing a php app on the websever I set up at my house. It is a fedora10 machine, running php5 and mysql. I have code like this:
<?php echo $var->function(); ?>
But for some reason the -> is closing the php tag, so the output has 'function(); ?' added to it...is there something I need to change in my php or webserver configuration?
I dont think that you have mod_php enabled in your apache config file, or else you would never see the php code in the output. Here is a good tutorial on setting up php 5 in apache.
Try
<?php echo("foo"); ?>
If that doesn't work, you don't have PHP enabled in Apache.
If your're sure that php is enabled, try this one
<?php
$result = $var -> function();
echo $result;
?>
to debug it a little.. maybe something interesting will raise
Is the php enabled on server? A simple test for determining it:
<?php phpinfo();?>
Put the above line in a .php file and access it.
You could also try this:
<?php phpinfo();
Final closing php tag isn't required.
I ran into a similar problem the other day but I was using
bar ?>
instead of
bar; ?>
It turned out that the short_open_tag option was disabled in my PHP configuration.
I had the same problem with a standard XAMPP installation.
short_open_tag=On
Solved it.