Saturday, December 31, 2016

Difference Between echo and print statements - PHP tutorial - Web development

echo and print - Output statements in php

                                 echo and print statement are merely same. Both are used to output in php. Difference between echo and print is an echo statement has no return value print statement has return value.

echo and print statement can be used with or without parenthesis echo or echo() and print or print(). 

example of echo and print statement :

echo "text".$variable;

print "Text".$variable;


example with echo and print statement below:


<!DOCTYPE html>
<html>
<body>

<?php
$x=10;
echo "<p>The value of x is".$x."</p>";
$returnval = print "<p>The value of x square is".$x*$x."</p>";
print "<p>The Return Value of print is".$returnval."</p>";
?>

</body>
</html>


Output of the above program:


Keep reading our blog to learn php free!. Thank you Readers.


Please Note:-

We are serving to our blog readers to post ad free for their business development. And educating them to develop their own website.

Please check our free websites and blogs. 

I am using php script for my website to post free ads - Please click the link and check it out 
http://www.freeadsimple.com

To Learn Basic HTML Please Read the article from http://webdevelopmentstepbystep.blogspot.com






Variable in PHP - php Tutorial free

Uses of variables in php

In php program, a variable should be followed by $ sign. Php will be considered a text as variable which is followed by $ sign.

Example :

$var_example


In php, we can use variables without declaring. For example if we want to use variable as text we can use like $text_Var="Wish you a happy new year 2017", $int_Var=546 and so on.

Example Program using variable:


           <!DOCTYPE html>
            <html>
            <body>

            <?php
           $x=10;

           $y=5.5;
           $z=$x+$y;
           $result_Txt="This is the Output of $x+$y is :   ";
           echo $result_Txt.$z;
           ?>


           </body>
           </html>








Global an local variables:

Global variables example


           <!DOCTYPE html>
            <html>
            <body>

            <?php
           $x=10; //global variable

           function insidefunction()
           {
            echo "The value of variable $x is in inside a function:".$x;
            }

            echo "The value of variable $x is in outside:".$x;
           ?>

           </body>
           </html>

Output of above program is 




The error was showing when run the function, So the global variable not into the function. and also first output in the function is not displayed. So, You can understand global variable is using in outside of the function. It will not affect inside the function values.

local variables

Now we are using the variable $x as local variable. It will affect only inside the function. It will not affect the outside value.

For example

<!DOCTYPE html>
<html>
<body>

<?php
function insidefunction() {
    $x = 10; // local variable inside the function
    echo "<p>Variable x inside function is: $x</p>";

insidefunction();

// using x outside the function will generate an error
echo "<p>Variable x outside function is: $x</p>";
?>

</body>
</html>


Output of above program is:





The error was showing when run the outside output, So you can understand local variable will not affect outside of the function. and also second output in the program is not displayed. So, You can understand local variable is using in inside the function wherever we are using.


Keep continue Reading Our blog to learn php! Thank you.

Please Note:-

We are serving to our blog readers to post ad free for their business development. And educating them to develop their own website.

Please check our free websites and blogs. 

I am using php script for my website to post free ads - Please click the link and check it out 
http://www.freeadsimple.com

To Learn Basic HTML Please Read the article from http://webdevelopmentstepbystep.blogspot.com












Friday, December 30, 2016

Comments in PHP - Web development tutorial free


Comments in PHP

Comments are not for run. That will be used to identify by programmer or others to understand the part of the codes and functionality.

Single line Comments

//Here you can put your comment. This line will not be executed. For comment purpose only.

##This also single line comment. 

Multi line Comments

/*This will be multi line comment. It has start point which is started in this paragraph. And it has end point just oppositely like */

Example:


<!DOCTYPE html>
<html>
<body>

<?php

//My Intro

echo "Hi! This is Manikandan. Wish you a happy new year!";


/*
This is a multiline comment this is not for execution. If you use php code here it will not be executed 
echo "Hi! This line will not be executed.";
*/

?>


</body>
</html>


In the above example I mentioned single line comment and multi lines comments in red letters. If you execute above program, the output will be 




For comments usage please try the above example program in your computer. Thank you! for reading. 



Please Note:-

We are serving to our blog readers to post ad free for their business development. And educating them to develop their own website.

Please check our free websites and blogs. 

I am using php script for my website to post free ads - Please click the link and check it out 
http://www.freeadsimple.com

To Learn Basic HTML Please Read the article from http://webdevelopmentstepbystep.blogspot.com




PHP Introduction - Free web development Tutorial



Introduction PHP

PHP is a server scripting language which is widely used to make dynamic web pages. A free scripting language. Easy to use in your web server for dynamic pages.

Example of PHP code:

<!DOCTYPE html>
<html>
<body>

<?php
echo "I am a php web developer!";
?>


</body>
</html>


inside HTML code we can use php code like above. Starts with <?php  end with ?>.

How to run php file?


                                                If we use php code in a page, to run that page we need to save as .php extension. Example “example.php”.

                                                We cannot run php normally as like HTML. We need a server software. In this example I am using Apache server. I will demonstrate how to run Apache server by Xampp software to run local host server.


I am using this software: Xampp software V3.2.2

You can download here and install it.
In server normally first page should be filename index.*.  if it is HTML index.html and if it is php web page the file should be index.php. Now create any folder to save this index file into a folder. Here I am creating a folder named “yourweb” into the folder “/xampp/htdocs” so the path of the index file “/xampp/htdocs/yourweb/index.php” . Code of index.php is 



<!DOCTYPE html>
            <html>
            <body>

            <?php
           echo "I am a php web developer!";
           ?>


           </body>
           </html>



Type this code in a text editor and save the index.php file into  “/xampp/htdocs/yourweb” folder.
Ok. Saved file. Now how we should run this file in web browser. Run xampp control panel in start menu. And click start “Apache” and “MySql” to run Apache server in local host.
Then you type the browser http://localhost/yourweb and enter now your index.php file will be open in your browser.
Like Below.


Output of index.php:





Please Note:-

I am using php script for my website to post free ads - Please click the link and check it out http://www.freeadsimple.com

To Learn Basic HTML Please Read the article from http://webdevelopmentstepbystep.blogspot.com





Try the first php file to run in your computer. Will continue in next lessons.