CH7 Introduction to PHP Flashcards
Scripting
a type of coding which requires writing step-by-step functions or processes
these are run automatically
increases the functionality of a programming language
e.g. C, C++, Java and Python
Web Apps
–apps that run on the web
–they are slowly gaining immense popularity
–these apps help to centralise and organise work effectively
–they do not require the user to download any application, this saves data
– written with a scripting language and then interpreted by the web server
PHP
Hypertext Preprocessor: widely used for creating web applications
Advantages of using PHP
- EASY TO LEARN: It shows similarities with C and C++ and it is commonly used.
- ADABTABILITY: Code written in PHP can be run on any operating system
- FREE AND EASILY AVAILABLE
- EXTENSIVE DATABASE SUPPORT: can use database services of different database applications
- SECURE: the safety features of web server is applicable to the app developed in PHP
- Does not require any memory-consumption for installation, use any text editor app
Basic Syntax of PHP
- starts with <?php and ends with ?>
- It is saved with the extension .php
- includes both HTML tag and some PHP code
echo statement
used to print the outcome on the screen
it can be used with or without a parenthesis
e.g. echo “Hello”;
echo (“Hello”);
keywords
reserved words that are language specific
each language has a different set of keywords that are understood by the compiler or the interpreter
e.g. and, break, for, if
Identifiers
–name the different components of a program
–like variables, methods and objects in a code
– they give names to abstract parts of a program
Naming Convention for Identifiers
–can only start with a letter or an underscore. A variable starts with a $.
–can be of any length
– mixture of letters, numbers, underscore and ASCII characters
–can be both uppercase and lowercase (case-sensitive)
–cannot use keywords
– no space is allowed
Literals
sequence of character that represent values which are stored as variables
it can be digits, letters or other characters
e.g. $v=20
here the literal is 20 which represents the value stored in $v.
Variables
- a character that can be assumed to have different values
- it is stored in the memory of the computer and can be used again
Naming Convention for PHP variables
- must start with a $
- can be of any length
- must not contain space
- both uppercase and lowercase letter can be used to name a variable
- case-sensitive
- made up of letters, digits and underscore
Operators
symbols that are used to perform arithmetic or logical operations in a given expression
1. Arithmetic
2.Comparison
3. Logical
Expression
a combination of variables, literals and other values
Operands
the variable or literal on which the arithmetic operation is being applies
Arithmetic Operators
basic mathematical operations, like addition, subtraction and modulus (%), are applied on operands
the operand can be a constant or a variable
Comparison Operators
–used to compare the values of 2 or more operands
–return a Boolean value after an expression is evaluated
–e.g. ==,!=,>,<
Logical Operators
–also called Boolean operators, they compare 2 comparison statements to form a conditional
–return in a Boolean value
–And (&&), OR (II), Not (!=)
Components of the Notepad++ window
TITLE BAR: shows the name of the current window which is opened and also the saved file
MENU BAR: showcases various option that are used to perform different activities like editing, debugging etc.
TOOL BAR: contains tools or commands that are frequently used.
CODE EDITOR WINDOW: the window which is used to write and edit the code
STATUS BAR: displays the status of the number of lines, columns, words etc.
FILE TAB: Notepad allows the user to simultaneously work on different files at the same time. They display different tabs for each file.
websites
Static Websites: do not share data between web pages and it remains unchanged
Dynamic Websites: share data among multiple web pages of the website
–more common nowadays
Differences between the GET and POST methods
–used by a website to share the user’s data among its web pages
–used inside the <form> tag to send the form data to the server
GET Method: uses the predefined $_GET variable for processing
»data is visible to everyone in the address bar
»not used to share sensitive information
POST Methods: uses the predefined global variable $_POST
»the data remains invisible to anyone