Hi ,
I have a windows vista service pack 2 system. I am running IIS and I have mysql installed and working. I ran the web platform installer and it created a subdirectory in c:\program files\iis express\PHP\v5.4. I also have changed the file defaults to point .php files to the php.exe in the this subdirectory I just referred to. When I get to the command line interpreter via cmd.exe I execute the command php -i and that works. If I make a small php script and type "php test.php" , that works also. However, if i go to the browser and execute a file with .html extension that has mixed html and php code, that only executes the html portion of the code in the chrome browser. Also if i just get into the php interpreter I don't get a prompt telling me I am there and nothing seems to execute there even though I put in valid php code. It just doesn't answer at all. This is IIS 7 and PHP 5.4 .
Thanks for any help
Php doesn't work in browser
Moderator: General Moderators
Re: Php doesn't work in browser
What if you use the .php file extension?johnorork wrote:If I make a small php script and type "php test.php" , that works also. However, if i go to the browser and execute a file with .html extension that has mixed html and php code, that only executes the html portion of the code in the chrome browser.
Re: Php doesn't work in browser
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Also I ran this in c:\inetpub\wwwroot\testp.php and it still only exectes the html code (displays the header).
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Also I ran this in c:\inetpub\wwwroot\testp.php and it still only exectes the html code (displays the header).
Re: Php doesn't work in browser
Here is a new piece of information: When I went into the IIS Manager and used the Handler Mappings function I selected the Php54_via_FastCGI handler. I just looked at it and pressed ok. The Manager popped up an error saying that if I had spaces in anywhere in the pathname to the file that I should use double quotes. I tried that but nothing improved so I tried to use %20 for the space and that let me out of the error loop. I tried the .php program again but it still didn't work.
Re: Php doesn't work in browser
Since the IIS program is complaining about the space in the name of the files (program files and iis express) maybe it would be better to put the files and the initialization file for php in C:PHP so there would be less chance of an error? Just wondering.
Re: Php doesn't work in browser
Hi,
I uninstalled Php in the Program Files directory and reinnstalled it in the c:\php directory and changed all environment variables and appropriate references and pointers and php 5.5.9. now works well. It works in the command line and works in the browser and works with mixed html and php code . Even entering php from the command line and putting in code in php will work once I press control-c. That is maybe my last question. Is there supposed to be a php prompt when you get into the interpreter? Anyways thanks for not answering - it forced me to think things out on my own.
I uninstalled Php in the Program Files directory and reinnstalled it in the c:\php directory and changed all environment variables and appropriate references and pointers and php 5.5.9. now works well. It works in the command line and works in the browser and works with mixed html and php code . Even entering php from the command line and putting in code in php will work once I press control-c. That is maybe my last question. Is there supposed to be a php prompt when you get into the interpreter? Anyways thanks for not answering - it forced me to think things out on my own.
Re: Php doesn't work in browser
My guess is nobody answered because nobody uses IIS. To answer the one question I can answer, yes, PHP displays a prompt in interactive mode.
Code: Select all
[~]$ php -a
Interactive mode enabled
php > $date = new DateTime();
php > echo $date->format('F j, Y') . "\n";
February 6, 2014
php >