开发者

"Hello, World" in PHP

It's a "Hello, World" code snippet. I have tried to run it using XAMPP, and I am u开发者_如何转开发sing Dreamweaver to write the code. Upon execution, the page does not display "Hello, World!". What would have went wrong?

<!DOCTYPE html>
    <head>
        <title>Hello World | Hello and Welcome</title>
    </head>

    <body>
        <?php
            Echo "Hello, World!";
        ?>
    </body>
</html>


You are trying to execute PHP code on an HTML page. All PHP files should have the .php extension (implied from the OP's comments). Change your filename.

PHP handlers don't work in .html pages for efficiency reasons. When you use .html instead of .php, you are telling the server not to embed PHP in that page, to save server resources.


Echo would be better as echo.

Is the file extension .php, not .html?

Is PHP configured on the web server?

Please check all those out.


Either you're not saving the file in a php extension so the PHP engine doesn't run on it or your server isn't set up properly

It's working fine on IDEOne


The answer to change the extension to .php is correct, because by default it would be a waste of server resources to actually read every file to see if it contains PHP code in order to decide whether it should execute PHP processing on it.

That said if you really wanted to you can probably configure the server to serve up any file extension as PHP, even a made up one. There's nothing magical about the extension other than how it's configured to be handled.


for hello world program in php just follow this tutorial
but before that you should have wamp server or xamp server on your pc
(wamp/xmap are open source software's and easily can found on google)
your 1st php program code:-

<?php
echo "hello world";
?>

output:- hello world Tutorial :https://www.youtube.com/watch?v=7qtqzhdEX-c
after this tutorial you can able to move other intermediate level programs of php.


PHP is generally case sensitive (see: http://php.net/manual/en/language.variables.basics.php).

So try changing Echo to echo.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜