Web Based Application Development using PHP Chapter 1 Expressions and Control Statements in PHP
Contents
History of PHP: • PHP is an "HTML-embedded scripting language" primarily used for dynamic Web applications. • PHP takes most of its syntax from C, Java, and Perl. • It is an open source technology and runs on most operating systems and with most Web servers. • PHP was written in the C programming language by Rasmus Lerdorf in 1994 for use in monitoring his online resume and related personal information. • For this reason, PHP originally stood for "Personal Home Page"
Versions of PHP • PHP2: • The code got another complete makeover, and in April of 1996, combining the names of past releases, Rasmus introduced PHP/FI(form interface). This second- version of PHP implementation began to truly evolve PHP from a suite of tools into a programming language in its own right. • PHP3: • PHP 3.0 was the first version that closely resembles PHP as it exists today. Finding PHP/FI 2.0 still inefficient and lacking features they needed to power an eCommerce application developers,began yet another complete rewrite of the underlying parser in 1997. In an effort to improve the language developes decided to collaborate in the development of a new, independent programming language. This entirely new language was released under a new name, that removed the implication of limitedpersonal use that the PHP/FI 2.0 name held. It was renamed simply 'PHP', with the meaning becoming a recursive acronym - PHP: Hypertext Preprocessor.
Versions of PHP • PHP5: • PHP 5 was released in July 2004 after long development and several pre- releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model and dozens of other new features.PHP's development team includes dozens of developers, as well as dozens others working on PHP- related and supporting projects, such as PEAR, PECL, and documentation, and an underlying network infrastructure of well over one-hundred individual web servers on six of the seven continents of the world. • PHP7: • The PHP development team released the latest version of PHP: PHP 7 claiming it to be twice as fast as its predecessor PHP 5. So, is migrating to PHP 7
Features and Advantages Of PHP: • Features Of PHP: • 1. Open Source • 2. Develops Dynamic Web sites • 3. Needs Web server to run • 4. Supports various datrabases. • Advantages of PHP: • 1. Free of Cost • 2. Open Source • 3. Platform Independent • 4. Easy to learn
Syntax of PHP: • Canonical PHP Tags:The script starts with <?php and ends with ?> . These tags are • also called ‘Canonical PHP tags’. Every PHP command ends with a semi- colon (;). • Let’s look at the hello world program in PHP: • <?php • // Here echo command is used to print • echo "Hello, world!"; • ?>
1.1 Variables in PHP: • Variables are used to store data, like string of text, numbers, etc. Variable values can change over the code. Here're some important things to know about variables: • In php variable is declared by following $ symbol. • In PHP, a variable does not need to be declared before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value. i.e $roll=34; roll variable will get auto declaration to integer. • After declaring a variable it can be reused throughout the code. • The assignment operator (=) used to assign value to a variable.
1.1 Variables in PHP: • <?php • $name="nilesh"; //String Variable Declared • $roll=7; //Int Variable Declared • $per=NULL; //Blank Variable Declared for later use • var_dump($name); //display output with data type and value • var_dump($roll); //display output with data type and value • var_dump($per); //display output with data type and value • $per=65.35; //assigning value • var_dump($per); //display output with data type and value • echo $name //display value • print $name //display value • ?>
1.2 Naming Conventions for PHP Variables • These are the following rules for naming a PHP variable: • All variables in PHP start with a $ sign, followed by the name of the variable. • A variable name must start with a letter or the underscore character _. • A variable name cannot start with a number. • A variable name in PHP can only contain alpha-numeric characters and underscores (A-z, 0-9,and _). • A variable name cannot contain spaces. • The variable name is case sensitive.
2. Constant in PHP • A constant is a name or an identifier for a fixed value. Constant are like variables, except that once they are defined, they cannot be changed. Constants are very useful for storing data that doesn't change while the script is running. • Common examples of such data include configuration settings such as database username and password, website's base URL, company name, etc. • Constants are defined using PHP's define() function, which accepts two arguments: the name of the constant, and its value • Syntax: define(“variable_name”,value) • Example: 1) define(“pi”,3.14); 2) define(“dept”,”CSE”);
3.Data Types in PHP:
4. PHP Operators & Expressions • 4.1 Expressions: • Expression is nothing but the combination of multiple variables along with Operator. • Example: &a+$b+$c; here a b c are variables and + is operator • $a>$b here a b are variables and > is operator.
4.2 Operators • Operators are symbols that tell the PHP processor to perform certain actions. • For example, the addition (+) symbol is an operator that tells PHP to add two variables or values, • while the greater-than (>) symbol is an operator that tells PHP to compare two values.
4.2.1 Arithmetic Operators
4.2.2 Assignment Operators
Comparison operators
4.2.4 Increament Decrement Operators
Logical operators
String operators
• Thank You

web Based Application Devlopment using PHP

  • 1.
    Web Based Application Development usingPHP Chapter 1 Expressions and Control Statements in PHP
  • 2.
  • 3.
    History of PHP: •PHP is an "HTML-embedded scripting language" primarily used for dynamic Web applications. • PHP takes most of its syntax from C, Java, and Perl. • It is an open source technology and runs on most operating systems and with most Web servers. • PHP was written in the C programming language by Rasmus Lerdorf in 1994 for use in monitoring his online resume and related personal information. • For this reason, PHP originally stood for "Personal Home Page"
  • 4.
    Versions of PHP •PHP2: • The code got another complete makeover, and in April of 1996, combining the names of past releases, Rasmus introduced PHP/FI(form interface). This second- version of PHP implementation began to truly evolve PHP from a suite of tools into a programming language in its own right. • PHP3: • PHP 3.0 was the first version that closely resembles PHP as it exists today. Finding PHP/FI 2.0 still inefficient and lacking features they needed to power an eCommerce application developers,began yet another complete rewrite of the underlying parser in 1997. In an effort to improve the language developes decided to collaborate in the development of a new, independent programming language. This entirely new language was released under a new name, that removed the implication of limitedpersonal use that the PHP/FI 2.0 name held. It was renamed simply 'PHP', with the meaning becoming a recursive acronym - PHP: Hypertext Preprocessor.
  • 5.
    Versions of PHP •PHP5: • PHP 5 was released in July 2004 after long development and several pre- releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model and dozens of other new features.PHP's development team includes dozens of developers, as well as dozens others working on PHP- related and supporting projects, such as PEAR, PECL, and documentation, and an underlying network infrastructure of well over one-hundred individual web servers on six of the seven continents of the world. • PHP7: • The PHP development team released the latest version of PHP: PHP 7 claiming it to be twice as fast as its predecessor PHP 5. So, is migrating to PHP 7
  • 6.
    Features and AdvantagesOf PHP: • Features Of PHP: • 1. Open Source • 2. Develops Dynamic Web sites • 3. Needs Web server to run • 4. Supports various datrabases. • Advantages of PHP: • 1. Free of Cost • 2. Open Source • 3. Platform Independent • 4. Easy to learn
  • 7.
    Syntax of PHP: •Canonical PHP Tags:The script starts with <?php and ends with ?> . These tags are • also called ‘Canonical PHP tags’. Every PHP command ends with a semi- colon (;). • Let’s look at the hello world program in PHP: • <?php • // Here echo command is used to print • echo "Hello, world!"; • ?>
  • 8.
    1.1 Variables inPHP: • Variables are used to store data, like string of text, numbers, etc. Variable values can change over the code. Here're some important things to know about variables: • In php variable is declared by following $ symbol. • In PHP, a variable does not need to be declared before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value. i.e $roll=34; roll variable will get auto declaration to integer. • After declaring a variable it can be reused throughout the code. • The assignment operator (=) used to assign value to a variable.
  • 9.
    1.1 Variables inPHP: • <?php • $name="nilesh"; //String Variable Declared • $roll=7; //Int Variable Declared • $per=NULL; //Blank Variable Declared for later use • var_dump($name); //display output with data type and value • var_dump($roll); //display output with data type and value • var_dump($per); //display output with data type and value • $per=65.35; //assigning value • var_dump($per); //display output with data type and value • echo $name //display value • print $name //display value • ?>
  • 10.
    1.2 Naming Conventionsfor PHP Variables • These are the following rules for naming a PHP variable: • All variables in PHP start with a $ sign, followed by the name of the variable. • A variable name must start with a letter or the underscore character _. • A variable name cannot start with a number. • A variable name in PHP can only contain alpha-numeric characters and underscores (A-z, 0-9,and _). • A variable name cannot contain spaces. • The variable name is case sensitive.
  • 11.
    2. Constant inPHP • A constant is a name or an identifier for a fixed value. Constant are like variables, except that once they are defined, they cannot be changed. Constants are very useful for storing data that doesn't change while the script is running. • Common examples of such data include configuration settings such as database username and password, website's base URL, company name, etc. • Constants are defined using PHP's define() function, which accepts two arguments: the name of the constant, and its value • Syntax: define(“variable_name”,value) • Example: 1) define(“pi”,3.14); 2) define(“dept”,”CSE”);
  • 12.
  • 13.
    4. PHP Operators& Expressions • 4.1 Expressions: • Expression is nothing but the combination of multiple variables along with Operator. • Example: &a+$b+$c; here a b c are variables and + is operator • $a>$b here a b are variables and > is operator.
  • 14.
    4.2 Operators • Operatorsare symbols that tell the PHP processor to perform certain actions. • For example, the addition (+) symbol is an operator that tells PHP to add two variables or values, • while the greater-than (>) symbol is an operator that tells PHP to compare two values.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.