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

Thursday, 16 February 2017

core php programming examples

Core php Programming Examples 


core php programming examples to swap two numbers 
<?php
$a=20;
$b=10;
echo  "a="." ".$a."  "."b="."  ".$b;
$temp=$a;
$a=$b;
$b=$temp;
echo "<br>";
 echo "after swapping A is"."  ".$a." "."and b is"."  ".$b ;
?>

core php programming examples to Fahrenheit temperature into Celsius 
<?php
$f=55 ;
$c=($f-32)*5/9;
echo $c;
?>
Program to print even numbers between 1 and 20 in php
<?php
for($i=1;$i<=20;$i++)
{
if($i%2!=0)
{
echo $i."  ";
}
}

Program in php to print first 10 natural numbers
<?php
for($i=1;$i<11;$i++)
{
echo $i ."  ";
}
?>

Program in php to generate pyramid
<?php
$i=1;
for($i=1; $i<=3; $i++)
{
for($j=1; $j<=$i; $j++)
{
echo '*';
}
echo '<br/>';
}
?>

Friday, 9 September 2016

Php Interview Questions and Answers for 4 Year Experience


Here in the post Php Interview Questions and Answers for 4 Year Experience , we are posting frequently asked questions of php in interviews, exams and viva voice. The main motive of the post Php Interview Questions and Answers for 4 Year Experience to give a brief idea of questions to interviewees and students at various levels of study.
php interview questions and answers

What is php?
How we write comment in php?
What are variables?
What are echo command?
Define string variables?
Write syntax for strops() function.
Write four comparison operators?
What is post decrement operators.
What is Numeric array?
Define the term loop.
Write syntax for request variable.
Define X+ file mode.
Which function is used to check the end of file?
What function is used to check the end of file?
Define the term queries in Mysql.
Define primary keys.
php interview questions and answers

Define Break statements.
What do you mean by PHP tags?
How we can echo variables in php? Explain with the help of example?
Write a program to print “Hello world” in php?
Mention php variables  naming convention?
Explain concatenation operator?
Explain if-else statement with an example?
What do you understand by Anonymous function?
php interview questions and answers for 4 year experience
What are multidimensional array?
Explain the term variable testing?
Write a program using switch case in php?
Write difference between while loop and do-while loop?
How we can create function in php?Explain with the help of example?
Difference between GET and POST method?
Brief explain various file handling modes?
Write code in Mysql to close the connection?
Explain where clause and order by clause of Mysql?
What are various network troubleshooting toold?Explain them in details?
What is Bluetooth?Writes its various applications?
php interview questions and answers


Simple PHP script to print first ten even numbers
<?php
for($i=0;$i<=20;$i++)
{       
          if($i%2==0)
          {
                   echo $i;
                   echo "<br>";
          }
}
?>
Simple PHP script to print first ten odd numbers

<?php
for($i=1;$i<=20;$i++)
{
          if($i%2!==0)
          {
                   echo $i;
                   echo "<br>";
          }
}
?>

Simple PHP script to swap two numbers using functions

<?php
$fn=10;
$sn=20;
echo "Before Swapping no:";
echo $fn." ".$sn;
echo "<br>";
swap($fn,$sn);
echo "After Swapping no:";
echo $fn." ".$sn;
function swap(&$x,&$y)
{
          $temp=$x;
          $x=$y;
          $y=$temp;
}
?>
Simple PHP script to print table of 5
<?php
$number=5;
$range=10;
for($i=1;$i<=$range;$i++)
{
          echo $i*$number;
          echo "<br>";
}
?>

Simple PHP script to print factorial of 5

<?php
$number=0;
$fact=1;
for($i=$number;$i>=1;$i--)
{
          $fact=$fact*$i;
}
echo $fact;
?>

Tuesday, 16 August 2016

Brief Introduction to PHP Programming Language For Beginners

Brief Introduction to PHP Programming Language For Beginners 


Objective of the post Brief Introduction to PHP Programming Language For Beginners   is to provide beginners as well as professionals a ready reckoner of PHP. We will try to provide the necessary knowledge of PHP Programming by this post.

Introduction To PHP Programming Language

   In today's time knowledge of HTML is not enough to develop good webpages.We can develop only static webpages.  But now a days the user need much more than that. User needs that which can virtually interact with it or the website which can communicate as well as fulfill all the demands of the user and also looking dashing page means more decorative page.

   All the above can be possible because of the one major thing that is –“PHP Programming Language

Moreover  Along with PHP you have to gain the knowledge of CSS and Javascript ...
Brief Introduction to PHP  Programming
Brief Introduction to PHP  Programming  For Beginners 

Big Question-  WHAT  IS THIS PHP PROGRAMING ?

PHP stands for recursive backronym called as hypertext pre-processor.

This is the open source software and it is easily available. PHP stands for hypertext processor. 
PHP is used for creating,designing website. Basically, PHP is a web server-side scripting language. 
In PHP the scripts are executed at the web server and their output comes in requesting browser that may be internet explorer,google etc. 
For executing PHP in system we need web-servor in which we executes apache and sql for using PHP language.
Infact PHP can connect many database engines such as my sql, oracle, postgre, Sqlite etc. 
Now a days PHP is widely used for creating interactive, needed websites  and E-commerce or driven websites are crafting by the use of only PHP
In HTML only structure of website is created and database is not required but in PHP data is stored in database.  

Basically, If I Say PHP Programming is programming which deals with the Server or which do the Server side Scripting.

WHAT IS THIS SERVER SIDE MEANS?


Server side means  that  when the website fetches and store the date from the web server…  

  
Now  u can understand   why you  have the need of leaning PHP programming…
Now lets us start talk about  PHP programming…

HISTORY  OF PHP Programming Language


PHP COMES TO AN EXISTENCE IN 1994  AS IT IS A PRIVATE PROJECT OF RASMUS LERDORF…ACTUALLY RASMUS LERDORF IS CALLED AS THE FATHER OF PHP…WHO HAD CREATED A SERIES OF PERL SCRIPTS WHICH IS KNOWN AS THE  "PERSONAL HOME PAGE" FOR THE PRESERVATION OF HIS OWN WEB PAGE.
In 1995 these tools were packaged and released as CGI binaries as the "Personal Home Page/Forms Interpreter", which included support for web forms and communication with databases.
 
Brief Introduction to PHP  Programming
Brief Introduction to PHP  Programming  For Beginners 

  VERSIONS OF PHP Programming Language

1.)   THE FIRST VERSION OF THIS GRANT LANGUAGE WAS PHP/FI WHICH COMES IN 1995.
THE FULL FORM   OF  THE  PHP/FI IS PERSONAL HOMEPAGE TOOLS/ FORM INTERPRETER.
2.)      NOW TO OVERCOME THE FLAUS OF THE PHP/FI WITH PHP/FI 2 full form is PERSONAL HOMEPAGE TOOLS/ FORM INTERPRETER-2.
3.)    NOW, THE NEXT  VERSION NAME IS PHP-3
4.)    THAN AGAIN COMES THE NEXT VERSION NAMED AS PHP-4.
5.)    THE CURRENTLY  GOING  VERSION    OF PHP-5…
                      
                     WHERE TO USE...
*       By using PHP PROGRAMMING we can perform basic opertionslike  create, open, read,                                                      write, and close  files.
*     if you want to modify existing database you can easily create,add,modifyyour database  by using PHP PROGRAMMING.
*    Using PHP PROGRAMMING, you can restrict users to access some pages of your website. 

All PHP code must be included inside one of the three special markup tags :-

 Advantages of PHP Programming Language

# COST EFFECTIVE :-- As PHP is open source and easily available Programing   language. So it  makes Cost effective.

# PLATFORM INDEPENDENT:--   One of the main advantage of PHP Programing is that it can work on any platform whether it is window or it linux or any other.

#RISKLESS :--PHP programing Supports many layers which can supposed to be very riskless.

# EASILY CONNECTS WITH DATABASE :-  One of the essential feature of PHP Programing is that it can support connectivity with all the major database such as MYSOL, PLSQL , ORACLE, ETC….

# GREAT GUI :-- As User Wants much more than Simple user Interface so PHP provides the best Graphical User Interface………….     


     READY TO GO…
Now after reading all the above material  you are ready to go…

  SO,THE BASIC SYNTAX OF PHP IS…

#SYNTAX OF PHP:---
<? PHP
       ----------
    -------------
   ?>

# WHERE TO PUT THE PHP PROGRAMMING CODE….

The PHP script can be put under body tag or under the head tag. The script start with  <?PHP  and closed with the ?> tag.
Post Contributed By: Shivam Prabhakar, Rudrax and Rashmi.

Monday, 25 July 2016

what is php

What is PHP ?

The recursive acronym for php is PHP: hypertext preprocessor. It is widely used and accepted open source general purpose language for scripting like HTML. Php is so pouplar these days because of so many reasons. 


INTRODUCTION TO PHP
what is php
Php is the most popular language for scripting. Php is popular because it enhances web pages. Using php , You can desing login forms like create usernames and paswords. You can create data entry forms in php with validations. You can access database in using php. You can perform various database opertaions like insert , update and delete using Php.
 

Monday, 14 September 2015

PHP Keywords with Examples


  PHP Keywords with Examples


Keywords are the reserve words of a language. You can use a keyword for its defined purpose only. PHP is enriched in Keywords. All the keywords in PHP have some predefined meaning. You can not use this keywords other than their defined purposes.











php Keywords 1
php Keywords














php Keywords 1
php Keywords


Php Tutorial For Beginners With Examples Pdf Free Ebook


           Php Tutorial For Beginners With Examples Pdf Free  Ebook


Introduction to PHP



Variables in PHP

Constants in PHP

Rules for Variable Names in PHP

Adding Comments in PHP

Storing Values to Variables in PHP

Operators of PHP

Arithmetic Operators of PHP

Relational Operators of PHP

Logical Operators of PHP

Conditional Operators of PHP

Data types of PHP




Control Statements of PHP

If Statement of PHP

If - Else Statement of PHP
Nested Loop of PHP

Switch Case Statement of PHP

Looping in PHP

For Loop of PHP

While Loop of PHP

Do While Loop of PHP

Nested Loops of PHP

  
Arrays

Concept of Arrays in PHP
Types of Arrays in PHP
One Dimensional Arrays in PHP
Two Dimensional Arrays in PHP
Associative Arrays in PHP

Strings


String Functions of PHP


Functions

Concept of Functions in PHP
Library Functions of PHP
User Defined Functions in PHP
Recursion
Call by Value 
Call by Reference
Return Statement
Forms
MySQL





Thursday, 6 August 2015

Arithmetic Operators in php Examples


Arithmetic Operators in php Examples 


In this topic of Arithmetic Operators in php Examples , we will list arithmetic operators available in PHP. Like other programming languages, PHP also have arithmetic operators to perform various arithmetic operations like addition, subtraction, division , multiplication and exponentiation. We have one new operator in php which we do not have in C and C++, i.e. exponentiation operator.

 

Lets us explore all the PHP arithmetic operators one by one.


Operator for Addition in PHP

To perform addition operation we need plus operator. The operator for addition is ( + ) sign.


Suppose you wants to add two variables say A and B and result of the addition is to be stored in variable C.

$C=$A+$B


Operator for Subtraction in PHP

To perform subtraction operation we need minus operator. The operator for subtraction is ( - ) sign.


Suppose you wants to subtract value of  variable A from variable  B and result of the subtraction is to be stored in variable C.

$C=$B-$A

 

Operator for Multiplication

To perform multiply operation we need multiplication operator. The operator for multiplication is ( * ) sign.


Suppose you wants to multiply value of  variable A with value of  variable  B and result of the multiplication is to be stored in variable C.

$C=$A*$B
Operator for Division in PHP

To divide value of a variable by value of some other variable we need division operator . The operator for division is ( / ) sign.

Suppose you wants to divide value of  variable A by the value of  variable  B and result of the division is to be stored in variable C.

$C=$A/$B

Modulus Operator of PHP

Modulus operator of PHP is (%). 
When a number is divided by another number , the modulus operator returns remainder of this division.


Exponentiation Operator of PHP
 

The exponentiation operator of PHP is (**).
Suppose you supply $A=3**2;
After the execution of the above statement , A will have value 9.