Possible Duplicate:
PHP script not running on browser
I'm trying to work with PHP and am very new at it. I'm trying to just test the waters with a simple hello world program. I've tried it like this:
<html>
<body>
<h>Php File</h>
<?php echo "hello world";?>
<p>Did it work?</p>
</body>
</html>
and then opening the html file in my browser (currently chrome). Only the did it work?
part shows in the browser. Not the actual PHP stuff I'm trying to run. Any ideas?
I also tried it with
<html>
<body>
<h>Php File</h>
<form action="helloworld.php" method="post"></form>
<p>Did it work?</p>
</body>
</html>
As an HTML file, and then running the following PHP script in a file called helloworld.php
<html>
<body>
<?php
echo "hello world";
?>
</body>
</html>
I cannot figure out why neither is working. Please help me get past this easy part so I can get to the hard stuff!
PHP is not intended for execution in a browser. It is for web servers to execute, or other preprocessing on the PHP-installed computer. PHP runs in several incarnations when installed on a computer: from the command line.
Chrome: Right-click a blank space on the page and choose View Page Source. Highlight the code, then copy and paste to a text file. Firefox: From the menu bar, choose Tools > Web Developer > Page Source. Highlight the code, then copy and paste to a text file.
You can open current file in browser using following methods: Click the button Open In Browser on StatusBar. In the editor, right click on the file and click in context menu Open PHP/HTML/JS In Browser. Use keybindings Shift + F6 to open more faster (can be changed in menu File -> Preferences -> Keyboard Shortcuts )
PHP Is Not Part of Your Browser. And here's where things change from the easy, browser-centric view of the world. When you download a web browser, you get HTML, CSS, and JavaScript, but you do not get PHP. PHP scripts—which you'll soon be writing—have to be interpreted by the PHP interpreter program, called php.
You can't just open the file in your web browser. You need to run it in a web server. Depending on your platform there is
PHP is not intended for execution in a browser. It is for web servers to execute, or other preprocessing on the PHP-installed computer.
PHP runs in several incarnations when installed on a computer:
The web server use is common. A browser asks a web server to retrieve somepage.html. A webserver (like Apache, IIS, etc.) retrieves somepage.html and preprocesses it. If a PHP tag is detected, it calls the installed PHP system to parse the PHP tag. Any result is substituted into the web page being rendered. The web server repeats this process for all tags needing preprocessing, then delivers the rendered page over the network wire to the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With