Sunday, 30 June 2019

Ch-5 Identifier in PHP

Ch-5 Identifier  in PHP
Like C and other programming languages  we need to declare and define identifier in PHP also, to create memory name and store data in that particular memory name space.
But in PHP we have no need to specify data type of identifier.
  Identifier Declaration Rule:
         <?php
$a=10;
echo $a
?>
Output-10
1.  Start with any letter, number,underscore
(remember, can not use any other special character, only underscore allowed ) eg. $1a;$_a;
2.  Identifier is a case sensitive.eg. $a=10, $A=20; both are different
3.  Identifier name cannot be identical; means it cannot be match by predefine keyword.
    There are 2 type of Identifier:
1.  Variable
2.  Constant
Variable:
a.  Variable name followed by $ sign. For eg.
$a; here a is an variable declaration.
b.  Variable can be change as so many time for eg.
i.                  $a=10; , php automatic create integer type memory location and store 10 .
ii.               $a=15.8; , php automatic create floating type memory location and store 15.8 in place of 10.
<?php
$a=10;
echo $a;
$a=15.8;
echo nl2br("\n$a");
?>
Output
10
15.8
First time $a store 10, then it store 15.8.
Here nl2br is a line break or new line function
Remember, like C , \n can not directly use with echo

Constant:
a.  Constant value cannot be change during program life.
b.  Constant name cannot be followed by $ sign.
c.   Only starts with any letter or underscore.
d.  For create identifier as a constant ,we need define() function, with 2 argument:
i.                  Constant name and
ii.               Value of that constant
For ex. Define(‘a’,10);
a is a constant name and 10 is a constant value of a.
Difference between variable and reference variable
From above we already discussed about variable that, variable name stats with a 4 sign which hold such a value which can be edit or change.
Like a variable, there is a another type of variable available in php , known as Reference variable.
Reference variable starts with double dollar ($$) ,this variable is used for reference of predefine variable value.
With the help of variable reference we can change another related variable value.
For ex.
<html>
<head><title>strtest</title></head>
<body bgcolor="red" text="green">
<?php
$x="abc";
$$x=20;

echo '$x is'.$x,'  <br>$abc is',$abc,' <br>$$x is'.$$x;
echo "<br><br><br>";

echo "if I will change $abc is 80 by ($abc=80;) then further value will be";

$abc=80;
echo "<br> <br> <br> <br> ";

echo ' now the value of $abc is'. $abc ,' <br> new value of $$x is'.
 $$x ,'<br> $x is '. $x ;
?>
$x isabc 
$abc is20
$$x is20



if I will change 20 is 80 by (20=80;) then further value will be



now the value of $abc is80 
new value of $$x is80
$x is abc
change in $abc value also changes $$x value

There are also many way to print string in php , you can also code such above program like :
<html>
<head><title>strtest</title></head>
<body bgcolor="red" text="green">
<?php
$x="abc";
$$x=20;
?>
<p>value of $x is <?php echo $x ?> <br> value of $$x is <?php echo $$x ?>
and<br> $abc is <?php echo $abc ?><br></p>
<?php
$abc=80;
echo "<br>";
echo $$x;
?>
<p> now the value of $abc is <?php echo $abc ?> <br> new value of $$x is
 <?php echo $$x ?><br> $x is <?php echo $x ?></p>
</body>
</html>

Output:
value of $x is abc
value of $$x is 20and
$abc is 20
80
now the value of $abc is 80
new value of $$x is 80
$x is abc
OR
In above 2 program you can use html character set value in place of $ sign. For eg.
<?php
$x=90;
echo "&#36x value is $x";
?>
This program print :  $x value is 90

Wednesday, 26 June 2019

Ch-4 Basic of PHP Script


Ch-4 Basic of PHP Script
PHP syntax:
Php script can only be write within (<? Php    ?> ) tag, save by .php extension and save in xampp\htdocs.
For example : if you want to print hello world , you have to  do following-
Open notepad or notepad++,  then write there following code:
<?php
echo “hello world”;
?>
Save this program by any name suppose test1 and also this name is followed by .php extension. Like(test1.php) .
This program simply print hello world on PHP Server.
Echo
echo is a print command. In place of echo you may be write print. For ex.
<?php
print "good morning";
?>
Output :good morning

Print and echo
 Remember that, echo and print is a language constructs not a function. Function is always followed by () parenthesis.
In echo and print , this is your wish to apply or not apply () parenthesis with them.
Both are a language constructor . both can be write without double inverted quotes(”), but remember without quotes you cannot write more than one word. For example
<?php
print good;
?>
Output :good

There is also no necessity to apply semicolon(;) at end of instruction.
Difference between echo and print:
1.     echo does not have return argument, but print have a return argument 1. So, we can say that echo is faster than print.
2.   echo can consider more than one string like:
<?php
echo "good","morning";
?>
       Output :good morning
But print cannot consider more than one string
<?php
print "good","morning";
?>
It gives a parse error.

Use of HTML in PHP
In case, if you want to design your page by background color,text color etc , you have to embedded this  tag within html program. Like:
<html>
<head><title>first program</title></head>
<body bgcolor="red" text="green" >

<?php
echo "hello world";
?>
</body>
</html>

Technical Interview Question

1. How can PHP and HTML interact?
2.What are the main error types in PHP and how do they differ?
3. What is "echo" in PHP?
4.What is "print" in PHP?
5. What is the difference between "echo" and "print" in PHP?









Tuesday, 25 June 2019

Chapter -3 What is PHP



PHP originally created by “RASMUS LANDLORF” in 1995 with the use of C and Perl Programming language. For creating a visitors group on his page , that’s why in earlier PHP was known by Personal Home Page , but know a time PHP is known as PHP  hypertext preprocessor(a recursive acronym).  PHP is a server side scripting language it means PHP script run on server.

PHP is a powerful tool and also easily available in free(open source) with GPL(General Public License), used for website development. If you want to give better designing in your website, you can also embedded  php script  with html and css file.

So, we can say that PHP is a simply HTML file , which is save as by .php extension.

When PHP Script works:
Internet connection is works on client server architecture, where client computer send a request and server gives a response.  

As by your client computer, you can use browser software, to send a request.  Similarly, Server computer is also use php server software.

When user  send request by browser to Server to open a website . PHP server first manipulate web page by PHP script then after, server computer send response to client computer on web browser.
PHP script can be run only on server. So, if you want to  run php script on your system , first you make sure your system have a server software like XAMPP,WAMP,LAMP .

PHP Life Cycle

PHP Server software used inbuild Zend Engine as a compiler and run time engine. that's why Zend Engine also called a heart of PHP.

PHP life cycle work in 3 steps;

1. PHP script load on the memory by zend engine.
2.PHP script compiled by zend engine and create zend opcode.
3. opcode executes by run time engine ,then generate HTML file for send to client computer.

Technical Interview Question:
1. What is PHP?
2. Who is Known as father of PHP?
3. What was old name of PHP?
4. What is a name of scripting engine in PHP?
5. which programming language ressemble with PHP?
6. What do the initials of PHP stand for?
7. What is the main difference between PHP 4 and PHP 5?






Ch-1 Introduction


Why we have to study about Web Developer  :

As we seem in our today’s modern age each and every thing comes on Internet or online platform. Whether that is shopping center, medicine facility, school admission, paying fees or any bill,  or we need to search any kind of information, we all are simply go to internet and search their related sites.

So we need a website for do any kind of work in internet.

In future also people or Internet user will like to seems simple, Interactive or low weight and secure website.

As increasing demand to develop more attractive website, So company needs to recruit more website developer.

Or You can also be open your own self employed in field of  website development.

So website development skills, can help to make your bright and golden career.

Website
First we need to know what is website?
To understand website definition, we take example of register or note book. Note book is nothing, but it is only collection of pages , where :-
First page is special ,called index page which help us to refer wanted  pages and

Other pages are ordinary pages , where we get information about particular topic.

Similarly, website is a collection of multiple web pages where first page is called home page and other informative pages
                              

simply called web pages.

Again, home page and other web pages can be further divided into two parts:

Static webpage
Dynamic Webpage



Static Webpage is a such kind of pages  which cannot be update any information on server side.
 For ex. Information about school building.

But dynamic webpage is a powerful pages , which has a capability to update information on server side
For ex. When user can pay online electricity bill , after transaction database information automatic update on server side.
That’s why company needs more dynamic web developer ,instead of static we developer.

Language for website design and development: 

You need to know 4 type of computer language to develop interactive and responsive website.

  1. HTML
  2. CSS
  3. Java Script
  4. PHP

HTML term define as Hypertext Markup Language. Use to only design static webpage or website.

CSS is a cascading style sheet, used to make web page more attractive by enhance designing part of  HTML (HTML have a limited designing property , so we can use CSS along with HTML  for design webpage. )

Java script use to give dynamic  touch in HTML Webpage.It is  a client side scripting language,runs on a user computer’s browser.
PHP is a server side scripting language , use to run on server side computer.

It is a most powerful tool, used to create dynamic web page. 

Technical Inteview Question:
1. What is static and dynamic website?