0% found this document useful (0 votes)
7 views

Web Based Application development with PHP Unit 1

Safe and secure ? regarding the best part terms and condition .
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
7 views

Web Based Application development with PHP Unit 1

Safe and secure ? regarding the best part terms and condition .
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 9
(Clnit = ox: Expressions and control statements in PHP ) Unit — 01: Expressions and control statements in PHP + History and Advantage of PH + Sytaxof PHP, + Variables and constants, + Datatypes, Expressions and operators + Decision making Conta statement (tse, neste if switch, breakand continue statement, Lap contrelstrectured Elective-t ‘A)Data Sciences: Data Warehousing and Data Mining B) Web Based Applicaton developmce wth PHP Questions to be discussed: 1. Differentiate between HTML and PHP, ‘2. Whatis PH? White the advantage of PHP, 3. Explain history of FH 4. Faplainthe difernce between Client Side Scripting an Server Side Seripting 5 Differentiate between echo and print statement used in PHP. 6. Define operators Expiin diferent types of operators usedin PHP. Describe the datatypes used in PHP. Discuss the varius looping statements used in PHP with suitable example Explain “do-while” construct used in PHP. Writ a program to print your names times using it Unit - 0: ‘and control statements in PHP. What is PHP? PHP stands for Hypertext re-Processor. {is widely wed. open soure, server sdesripting language PHP isa powerful tol use by web developersto bill dynamic and interactive websites. ‘Their version of PHP was formulated by Rasmus Lerdorin 1994 Du 2th tt verso renin 2028, PHP fles save wth php extension ewe — Tepe om ser Advantages of PHI ‘4 PHP is open-souree and fre from cost 4 Itisplatiorm-independent © Wisma sed duc tits faster ate ofloading over slow internet sped [thelps in reusing an equivalent code and not got have to write lengthy code and sophisticated structure. © Tthelpsin managing coe easily. ‘© Tthas powerful library support wo use various function modules fr data representation, ‘® PHP sbultin database connection modules help in conncetng databases easily, ‘Unit = ot: Expressions and control statements in PHP Difference between HTML and PHP: —_—_t_s HT™L ae ent Server TM PHP HTML sa cent side cxipting langage ‘PP isa server-side srping lana. Developed by Tim Berner-Lae Developed by Rasmus Lar HTML codes are wate PHP codes are dyamie. tis seo create stato web pags. Wis used to create dynamic web pegs HDL vey ey olan, PHP cay tolara bt ot as muchas HTML. HIME sued for frontend development PHP is sed for server-side development. "HTML ca be aed ina PHD le PHP cant be weed aan HTML fle HTML Slessave with bend r Imetension. | PHP Sls sve with. php etenson (Unit ou: Expressions and control statements in PHP History of PHP: 4+ Rasmus Lendorf stared developing PHP in 994 [Alot 61 programs were writen by him which were used fr maintenance of his personal website + Hemodie these programs to make them work with web forms at interact with databases, “+The implementation ofthis moxifcation was termed as Personal Home Page/Forms Interpreter" (PHE/F1) ‘The ist version of PHP/FI was made available othe world by erdorfin June 1995. PHP 2 “+ After the fist version of PHE/FI, a development tam formed which worked for months to finally rease official version 2 of PHP/FT in ate 1997- As PIP was developed erganicalls there was tof inconsistency in function nares and parameter ode. PHP Version Tlie «+ e+ 0 ra mrss ty gr ms Unit - ou: Expressions and control statements in PAP PHP3 +The parser was rewritten in 1997by Zev Surask and Andi Gutmans which led tothe formation of PHP. + After ehanging ts name to PHP which meant Hypertext Preprocessor, ts public testing was state + PHF3 was officially launched in June 1998 PHP 4 + Zend Engine 1.0 powered PHP 4 was released in May 2000, + PHP 4 reached its version 4.4.9 in August 2008. vues + Poweredby Zend Engine 2, PHP 5 was unched in July 2004, + Thad features like PDO Extension, improved support for OOPS and many ether performance improvements PHP Version Timelines o¢—_—__—___+___#—__+—__- ram rwao Fury mip; riry mars 5 7 00 mot = 0 (Unit ox Expressions and control statements in PHP PHP 6 (Never Released) + Dueto the lick of support for native Unicode, PHP received med reviews, + A projet wasnitiated in-2005 to introduce native Unicode support through PHP. ‘+ This project was headed by Andrei Zmievsk.As it would require major changes, it was decided to launch this update asa new version naming it PHP 6.0. + Butte shortage of developers who understood the necessary changes resulted ia the delay ofthe projec. + Considering this delay, PHP 5.a was released in 2009 which included mans features rom the PHP 6 projet “+The project development wasstopped in March 2010. PHP 7 Another major version of PHP was developed in 2014 and 2035. ‘Thissersion was tected as PHP 7 which caused seme cfusion as PHP 6 was never reas PHP 7 was also known as PHP next generation phon) ‘PUP Version Tnlines «2 ee ee» __e sa oe me ‘oot = Ky ‘Unit - ox: Expressions and control statements in PHP PHP 8.0: ‘+ On the 25th year of PHP history, PHP 8.0 was developed in Nov. 2020. ‘+ PHP 83, released in 2021 ‘+ PHP 8.216 the test PHP version. “+ PHP 83 isthe setve development branch of PHP versions. Is the current target for new RECS, and is scheduled to be released towards the end of 2023. PRPVarsonTinlioes oe 8 8 8 ee rer rmmrizo, ty, RSmty my 93 a bat ‘Unit - 01: Expressions and control statements in PHP Syntax of PH + A PHP script starts with

: (Unit = ot: Expressions and control statements in PHP echo and print Statement 2 Wefrequenty use the cchostatement to dsplaythe output. {2 Thereare two basic ays to gt the ouput in PHP: 4 echo print Difference between echo and print: ‘echo print ‘ ‘+ AHP script can be placed anywhere inthe document, ‘+ APHP script is executed on the server, and the result is sent back tothe browser. + PHP statements end with semicolon. ‘and control statements in PHP PHP Variables: + A.vatiable isthe name of the memory location that holds data, + Variables are also known as “containers” for storing information, + In PHP, a variable is declared using a $ sign followed by the variable name. Rules for declaring PHP variable: > Avariable must start witha dollar ($) sign, followed by the variable name. >It can only contain alpha-numeric character and underscore (A-z, 0-9, _) > Avariable name must start with a letter oF underscore (__) character. > Variable name cannot start with a number or special symbols, > APHP variable name cannot contain spaces. + Variables are case-sensitive. PHP Constants: PHP constants are name or identifier that can't be changed during the execution of the seript. + Constants are similar tothe variable except once they defined, they can never be undefined or changed. ‘They remain constant across the entire program. + PHP constants follow the same variable rules, that means it can be start with a letter or underscore only. Use the define( function to create a constant, Syntax: define(name, value, ease-insensitive) ‘name: It specifies the constant name, value: It specifies the constant value, cease-insensitive: Specifies whether a constant is case-insensitive, Default value is false. t means itis case sensitive by default, PHP Data Types: + Data Types define the type of data a variable can store. + PHP data types are used to hold diferent types of data or values. + PHP supports 8 primitive datatypes that can be categorized farther in 9 types: 4. Scalar Types (predefined) 2. Compound Types (user-defined) Special Types PHP Boolean ooleans are the simplest data type work ike swith It holds only two values: TRUE (1) or FALSE (0). {soften used with conditional statements, the condition is correct, it returns TRUE otherwise FALSE. -_ PUP Integer Inger means numeric data with nesative or postive sgn holds only whole numbers, ie, numbers without fractional part or decimal points. PUP Float + A floating-point number sa number with a decimal point + Team hold numbers with factional or decimal point, inloding a negative or positive sign. PHP string string isa non-numeric datatype. Iholdsleters or any alphabets, numbers, and even spc characters. + String values must be enclosed either within single quotes orn double quot PHP Array + Amarray isa compound datatype, = Teeamstore multiple values of same datatype ina single variable. PHP object + Objects are the instances of user-defined clases that cam store both values and functions. + They must be explicitly declared PHP Null + Nallisa special datatype that as only one value: NULL + Thereisa convention of writing it in capital letersas itis case sensitiv. + The special type of datatype NULL. defined a variable with no value. PHP Resource + Resources are not the exact dat ype in PHP. + Basia, these are used to store some function calls or references to extemal PHP resources. ‘Unit ~ 01: Expressions and control statements ie PAP PHP Operators: An operator isa symbol that tll to the compiler which operations tobe performed between the operands. Basically, it is used to perform operations an operands. In simple words, operators are used to perform operations on variables or values. ‘An operator takes some values (the operands) and does something, ‘There are different types of operators in PHP: Arithmetic operators + Logical operators s Conditional(Ternary) operators ‘+ Assignment operators + Comparison(Relational) operators «Increment/Deerement operators > String operators Array operators Unit 0: Expressions and contra statements in PHP Set up PHP on your own PC 1. PHP 2. Database(MySQL) 3. Server(Apache) ‘Third Party Software > WAMP, ‘Windows, Apache, MySQL, PHP > LAMP Limux, Apache, MySQL, PHP > MAMP ‘MacOS, Apache, MySQL, PHP > Xampp Cross-Platform, Apache, MySQL. PHP-Perl Decision Making control statements: Like other language PHP also allows us to perform actions based on some type of conditions. Ws just like a two-way path, + Ifyou want something then go this way or else turn that way. + Touse this feature, PHP provides us with four conditional statements: + if'statement 2 if.else statement if..clseif..clse statement 4 switch statement if Statement: if..clse Statement: c understood that ifa condition will hold TRUE or FALSE. + Ifacondition is TRUE then if block gets executed, otherwise else block gets executed. ‘Syntax: ‘and control statements in PAP if, elseif..else Statement ‘This allows us to use multipeif..else statements. We use this when there are multiple conditions of TRUE cases. + is also called nested if-else statement. Syntax: switch Statement: ‘The “switch” performs in various eases i... it has various eases to which it matches the condition and appropriately executes a particular case block. It first evaluates an expression and then compares with the values of each case. + Ifacase matches then the same case is executed. + Touse switch, we need to get familiar with two different Keywords namely, break and default. 1, The break statement is used to stop the automatic control flow into the next eases and exit from the switeh case 2, The default statement contains the code that would execute if none of the eases match Syntax: Unit and control statements in PHP Break and continue statements: + Just like other programming languages, PHP also have two keywords break and continue. + Itis used to control the loop. + These statements are known as jumping statement or flow of transfer in the program. = an ==» w= cnt Break: + The break statement is used inside the loop (for, foreach, while and do-while) and switch case statement As the break statement encountered inside a loop, it immediately terminated the loop statement and transferred the control to the next statement, followed by a loop to resume the execution. + Tt is also used in the nested loop statement, where it breaks the inner loop first and then proceed to break the outer loop. + It is also used in the switch case statement to terminate a particular case's execution in the proseam Continue: The continue statement is used in the middle of for loop, while loop, do-while loop, and the farcach loop. As the continue statement is encountered in a loop, it skips the current iteration of the loop and transfers the control to the beginning of the loop for further execution of the loop. For example, in some situations where we want to skip the program's current statement and then starts the next statement, we use the continue statement.

You might also like