31 August 2018

How to Write PHP code and HTML code within a same file

  • A PHP file can have both PHP code and HTML code together.
  • Any HTML code written outside of PHP <?php //php code here… ?> Code is ignored by the PHP parser which allows PHP files to have PHP code and HTML code in a same file.
  • A PHP file must have “.php” extension. 
  • Sample “index.php” file code is given bellow:

  •  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    <!DOCTYPE html>
    <html>
    <head>
    <title>Web Page Title</title>
    </head>
    <body>
    <?php
     echo "<h1>HTML Code inside PHP code </h1>";
    ?>
    <h1>This is a Heading</h1>
    <?php
     echo "Today's Date is ".date("d-m-y");
    ?>
    <p>This is a paragraph.</p>
    
    </body>
    </html> 
    
  • Output of above code:
  • HTML Code inside PHP code

    This is a Heading

    Today's Date is 01-09-18
    This is a paragraph.
    
    

# Book on PHP:


Learning PHP, MySQL & JavaScript: With jQuery, CSS & HTML5 (Learning PHP, MYSQL, Javascript, CSS & HTML5)

28 August 2018

What are PHP tags?

  • PHP code starts with start tag <?php and end with end tag ?>
  • PHP code can also start with short open tag <?  .To use this short tag you have to enable short_open_tag in php configuration file “php.ini
  • Before PHP version 7, PHP  also supported ASP tags <%, %>, ASP short open tag for <%=, and the script tag <script language="php"> which  has been removed from PHP version 7.
  • If  a PHP file have only PHP codes inside the file  then it is preferable to omit the PHP closing tag ?> at the end of the a PHP file.
  • Example of PHP Tag
  • 1
    2
    3
    4
    5
    <?php // Start PHP Tag
     echo "PHP is easy to learn !!";
     echo "PHP code is executed on web server !!";
    
     // End PHP Tag ?> 
    

  • Output of above PHP code:
    PHP is easy to learn !!PHP code is executed on web server !!

# Good book on PHP:



PHP for the Web: Visual QuickStart Guide (5th Edition)

26 August 2018

What are the Functionalities of PHP?

PHP is a powerful programming language which can be used to develop almost any kind of websites. Some most popular php functionalities are given bellow:

  • PHP is widely used to make dynamic web pages within very short time.
  • Send & Receive Email with PHP is very easy.
  • PHP can quickly Generate, Read, Write, Delete, Open and Close any files on the web servers.
  • PHP is perfect language to work with data Select, Insert, Delete, Update records in database.
  • PHP can be used to collect data from registration form, Login from etc forms.
  • PHP can Send and Receive cookies data stored on client machine.
  • PHP can store session data on servers.
  • PHP can be used to Control user-access on websites.
  • PHP can Encrypt data securely.
  • PHP can Compress files.
  • PHP can be used to Resize & photo enhancement. 
  • PHP can easily create PDF files ,XML Files, Flash files etc for websites.

Why should you learn PHP?



  1. PHP is easy to learn.
  2. PHP Web developer has huge demand in Job Market.
  3. PHP runs on various platforms like Windows, Linux, Unix, Mac OS etc.
  4. PHP supports a wide range of databases like Oracle, MySql, PostgreSQL, MongoDB etc
  5. PHP is free.You can download PHP from the official PHP websites: www.php.net
  6. PHP is a widely-used open source scripting language
  7. PHP is used to make Facebook, Wordpress, Yahoo etc websites.
  8. PHP is the best language which should be know by all web developers.
Head First PHP & MySQL: A Brain-Friendly Guide

What is PHP?


  • PHP stands for "PHP Hypertext Preprocessor" 
  • PHP is a widely-used general-purpose scripting open source scripting language.
  • PHP is especially used for web development and PHP can be embedded into HTML.
  • PHP scripts are executed on the web server.
  • A PHP script starts with start tag "<?php" and ends with end tag "?>" 
  • PHP files have extension ".php". Example of some php files can be index.php, about.php, home.php, contact.php
  • PHP is a powerful programming language which has been used to create Facebook, Wordpress, Yahoo etc websites.
  • Sample PHP Code:
  •  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    <html>
        <head>
            <title>Example</title>
        </head>
        <body>
    
            <?php
                echo "Hello World!";
            ?>
    
        </body>
    </html> 
    

  • Output of the above PHP Code:
    Hello World!

Beginning PHP and MySQL: From Novice to Professional

Featured Post

How to Write PHP code and HTML code within a same file

A PHP file can have both PHP code and HTML code together. Any HTML code written outside of PHP <?php //php code here… ?> Code is ig...

Popular Posts