Showing posts with label php tutorials. Show all posts
Showing posts with label php tutorials. Show all posts

Tuesday, 11 February 2014

Echo Statement in php


Echo statement
Echo Statement
Echo Statement php programming Languages. This is a tutorial about Echo Statement. Echo Statement is not function. In php the two basic constructs to get output are echo and print. print statement will see in next tutorial. Echo is language constructs within php that allows us to output data string to the user browser. Its allows us to output basically on the screen.

Echo Statement code (Screenshot) :-


echo statement
Echo Statement
<?php

echo 'Hello world';

?>
In screenshot is the example for how we can use echo statement and the output screenshot. Now we can also use html tags in php for example

Output (screenshot):-

Echo Statement
Output Echo Statement



In example of code we had echo statement after echo we can use single quotation mark(‘) or double quotation mark(”) and you will learn about this when, why and where you should use quotation marks. Basically Double quotation mark allows you to output variables inside program before that you should know what are variables are. But this tutorial is about echo i am not going in so detail later on this will explain in detail. and semi colon (;) is used to end of the line in echo statement and also separator for two echo statements used one by another otherwise we can get some errors for example see Screenshot1 and Screenshot2.

echo statement
Screenshot1

echo statement
Screenshot2


html tags in php code (screenshot 5) :-

html tags in php
Screenshot5



<?php

echo "<strong>Hello world.</strong>";

?>
output screenshot 6:-

Echo Statement
Screenshot6
In this example you had idea how we can use html tags in php. And also Echo statement uses for echoing output to the browser.
Read More

Monday, 10 February 2014

Code Indentation in php


Code Indentation in php programming languages. Now this tutorial i will explain what is code indentation is and why it is used ? For example see Screenshot now this file works perfectly. Now Screenshot is output of file shown in screenshot. In screenshot Output is You’re Over 21 Yes,1 is equal to 1! Now lets see code part in screenshot If name is equal to alex it will run part



Code Unintended :-
Code Unintended
Code Unintended
php output

<?php
$name='Alex';
$age = 21;
if(strtolower($name)==='alex') {
if($age=21) {
echo 'You\'re over 21';
if(1===1) {
echo'yes, 1 is equal to 1!';
}
}
}else {
echo 'You\re' not Alex';
}


and If we change name is equal to Dale Screenshot

code
Changing name to dale
Output will be You’re Not alex! Screenshot
php code output
Output will be You’re Not alex!

It will run lower part of the code

else{

echo 'you\'re not Alex!';

}

Now problem is in this code there is not code indentation therefore its hard to say where if statement starts and when if statement is close and where is else statement is. So we Need to do modification to program. It will be lot harder if we not do code indentation. Now you seen in screenshot1 its a 14 lines of program or script you can say imagine if we have 14 thousand line program or scripts and we do not used indentation. you can imagine how  messy it look. Now let we write code in proper manner.

Code Indentation Code (ScreenShot) :-

Code Indentation
Code Indentation
<?php
$name='Alex';
$age = 21;
if(strtolower($name)==='alex') {
   if($age=21) {
     echo 'You\'re over 21';
     if(1===1) {
     echo'yes, 1 is equal to 1!';
     }
  }
}else {
echo 'You\re' not Alex';
}
Now in this code what i had done is after first if statement i had done code indentation or second if statement inside second ifstatement i had code indentation to third if statement. Now you can see view of code indentation how its change look of the file. So always use code indentation to you code. its a standard methods to write codes. Its very important when you distributing code or you need other people to read code. you may understand it works and it may be work in fact but others can not understand and its also difficult to make quick modification to your code without code indentation.
Read More

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates