PHP - Write First Program on PHP

As you know PHP is server side scripting language. Let me explain few lines on how PHP works with Apache server? First of all, user will send a request through application layer or web browser to the server via the protocol.

As you know PHP is server side scripting language. Let me explain few lines on how PHP works with Apache server? First of all, user will send a request through application layer or web browser to the server via the protocol.

And the server will respond the request by sending HTML file back to the browser. It means we have a .php extension of the file but the server will not display .php file, It will show you only HTML file.

That is the basic working mechanism of server side scripting language via Apache server.

PHP SYNTAX

PHP has it's own syntax to write code, syntax means rules to regulate and formulate the code in the well mannered form.  
<?php // will define this is the beginning of PHP programming code.  
?> // will define this is the end of PHP programming code.  
First Program on PHP

PHP CODE 

<html>
    <head>
        <title>
            First PHP
        </title>
    </head>
    <body>
    <!-start of php code->
    <?php
        echo 'This is My First Program on PHP';
    ?>
    <!-end of php code->    
    </body>
</html>

OUTPUT

You need to run Apache server to execute your .php file. Below the output you can see the inspect element, there you can see only the HTML code, not PHP code. PHP code is not visible to users through a web browser. It will remain visible on the server only.  
Apache server returns html only
Apache server returns HTML only
PHP code is hidden
If you do view source on you browser the also you can't get the PHP code

You May Also Like...

Subscribe Us