






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
the notes of php from n phsakgfdsdhfdhfhdhguifdhidhvds
Typology: Exams
1 / 11
This page cannot be seen from the preview
Don't miss anything!







Download the code used in the lesson. PHP_introduction.zip
Instructions to open zip file. The instructions file is present in every zip folder also.
Note : echo statement is not case sensitive. ECHO/echo/Echo means the same in PHP.
Boolean variables
Boolean variables contain only TRUE or FALSE as values. $var = TRUE; This is boolean variable. TRUE or FALSE should not be in quotes. Then it will be considered as strings.
Arithmetic Operations It usually includes addition, subtraction,multiplication, division, modulus which gives the remainder of the division and exponentiation.
Example Name Result $a + $b Addition Sum of $a and $b $a - $b Subtraction Difference of $a and $b $a * $b Multiplication Product of $a and $b $a / $b Division Quotient of $a and $b $a % $b Modulo Remainder of $a divided by $b $a ** $b Exponentiatio n
Result of raising $a to the $b th power. Introduced in PHP 5.
Logical Operations Logical operators, Relational operators are used for comparisons. These are the valid operators for PHP. These operations either evaluate to TRUE or a FALSE state.
Example Name Result $a and $b
And TRUE if both $a and $b are TRUE, FALSE otherwise
$a || $b Or TRUE if either $a or $b is TRUE. If $a is TRUE and $b is false then also this condition will output true as one of the two options or both the option should be true in OR case $a xor $b
Xor TRUE if either $a or $b is TRUE, but not both; otherwise FALSE
! $a Not TRUE if $a is not TRUE, otherwise FALSE $a % $b Modul o
Remainder of $a divided by $b
http://www.mytoptutorials.com/php/tag/php-multidimensional-arrays/
Difference between single quotes and double quotes:
Single Quotes Double Quotes Double quotes inside single quotes will be considered as strings.
Single quotes inside double quotes will be considered as strings. Variables inside single quotes will be considered as strings and will display the variable name only.
Variables inside double quotes will be considered as variables only and will display the value of the variable instead of name. Input: $variable = 5; echo 'The output is $variable.';
Output: The output is $variable.
Input: $variable = 5; echo "The output is $variable.";
Output: The output is 5.
Commonly used string functions are:
Consider the following link of official bootstrap manual for all possible string functions in PHP. Sting Functions
If condition could be used without else part. if($marks == 40){ echo "Just passed"; }
If-else statement can be used inside another if else statement.
Note : Please find the solution of the code challenge in the helper text of previous two lessons of
this topic
uidelines : Form tag contains two attributes: action and method.
Difference between GET and POST:
GET POST Values appear in the URL Values do not appear in the URL Values can be bookmarked Values can not be bookmarked There is a limit on characters which can be sent through URL.
There is no limit on the characters send through POST request. Less secure More secure
Code and explanation of user_registration.php
Instructions:
Note : Please find the solution of the code challenge in the helper text of previous two lessons of this topic.
Header function
The header() function sends a raw HTTP header to a client. In simple words, header redirects the user to another page. Suppose we want logged out user to open only index.php page. If logged out user tries to open any other page, it should be redirected to index.php page.
Code:
Header function takes a string parameter (location: name_of_the_web_page.php).
Header function should be used before we echo or display any HTML element because user will be redirected as header fucntion is encountered in the code.
Code Challenge:
Store page views in the session variable. Instructions:
Code Challenge:
Store page views in the session variable. Instructions:
1
2
3
4
HTML5 validations 5
6
7
8
9
10
11
12
13
14
15
16
Signup Form 17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Submit 33
34
Q. Can you explain me in simple terms the use of the isset() function?
isset() function is used to check if the variable is set with some value. For example:
if(isset(($_POST['form-username'])) { //run the script in brackets }
Q. Can isset() function be used to redirect php page to another php page?
The isset() function is used when there are functions to be performed if any input type is set. We always use isset with loops. E.g.
if(isset($_POST['submit']){ -- code --}.
It cannot redirect php pages to another but can be used as a condition to redirect. E.g.
if(isset($_POST['submit']){ header('location:home.php'); exit; }
This code will redirect the web page if the submit button is set to home.php page.
see more
Q. In HTML forms, what's the difference between using the GET method versus POST? Practically when should we use POST and GET?
Ask your doubts to the instructor personally if they are not already answered on forum.
Next live chat: Today (7:00 - 8:00 PM)
For any queries, please write to us at [email protected] © Copyright 2016 Internshala