Showing posts with label PHP Syntax. Show all posts
Showing posts with label PHP Syntax. Show all posts

Monday, April 15, 2024

PHP Syntax


PHP Syntax

PHP Syntax


PHP Syntax:-

 1]  PHP is a server-side coding language widely used for web development. 

 2] PHP code is often embedded in HTML

 3] PHP files usually have save the ".php" extension.

 4] PHP file contains the HTML tags   some PHP code.

 5] PHP script that uses the built-in PHP function "echo" to display text

PHP's syntax is similar to the C language. PHP is a server-side coding language. PHP code is stored as a text file with the ".php" extension. A ".php" file is essentially a web page with HTML text interspersed between one or more blocks of PHP code. 

However, it must be opened in a browser with HTTP protocol URLs. In other words, if you double-click on the PHP file icon, it will open locally using the file protocol. For example, if you open the "index.php" file in the root folder of the Apache server, only the text of the PHP code will be displayed. However, if you start the Apache server and

 open the URL http://localhost/index.php, the Apache home page will be displayed. Therefore, a PHP parser needs to distinguish between PHP code and other content. When the ".php" file is opened on the website, the HTML engine performs the HTML/CSS/JavaScript part and runs on HTML blocks when it encounters the words contained in the PHP tags. The PHP parser process blocks the response and passes it back to the browser.


Syntax :-

<?php

//php code here


?>

PHP Syntax:-

Example :-

<!doctype html>
<html>
    <head>
        <title>html code and php code</title>
    </head>
<body>
    <h1>MY FIRST PROGRAM IN PHP </h1>
    <?php
    echo "Hello friends
     How are your
        fine "
         ?>
</body>
</html>


PHP Syntax 

Output :-

php syntax/output




Read more

php array type

php for loop

php switch statement

php string operators

php data type