WEB PROGRAMMING USING PHP
WEB PROGRAMMING USING PHP
CSS selectors:
We can divide CSS selectors into 5 categories:
1. Simple selectors
2. Combinator selectors
3. Pseudo class selectors
4. Pseudo element selectors
5. Attribute selectors
CSS selectors are used to find or select the HTML elements you want to style
Simple selectors select elements based on name, id and class
Combinator selectors select elements based on a specific relationship between them
Pseudo class selectors select and style a part of an element
Whereas pseudo element selectors select elements based on a certain state
Attribute selectors select elements based on an attribute value
OR
CSS selectors are used to find or select the HTML elements you want to style.
2. CSS id selector:
The class selector selects elements with a specific class attribute. It is used with a period
character.
The universal selector gives the style to all the elements on the page. Symbol used is *.
The grouping selector is used to give the style to a group or multiple elements with the same
style definitions. It reduces the length of the code.
PHP datatypes:
Data types define the types of data that a variable can store.
PHP supports a wide range of data types, like string, integer, float etc. Data types make it
easier to store and handle information in programs.
1. String:
2. Integer:
They represent whole numbers without decimal numbers. It includes either negative and
positive numbers.
3. Float or double:
4. Array:
5. Boolean:
A Boolean represents two possible states (true or false). They are often used in conditional
testing.
6. Object:
7. NULL:
8. Resource:
1. Arithmetic operators
2. Comparison operators
3. Logical operators
4. Assignment operators
5. Conditional operators
Arithmetic operators:
Comparison operators:
Comparison operators are used to find the relation between the variables.
Logical operators:
Assignment operators:
The CREATE statement is used to create a table. This includes adding new records where we
can fill in the values.
INSERT
The INSERT statement is used to add new data into a table. It allows you to specify the
values for each column.
UPDATE
The UPDATE statement is used to modify existing records in a table. It allows you to change
the values of specific columns based on certain conditions.
DELETE
The DELETE statement is used to remove records from a table based on certain conditions. It
allows you to specify which rows you want to delete.
SELECT
The SELECT statement is used to display certain records, group of records or the whole table
(by using *).
The die() function is an alias of exit() in PHP. Both result in termination of the current PHP
script when encountered. An optional string if specified in the parenthesis, will be output
before the program terminates.
die("message");
Using die() for error handling is considered an ungainly and poor program design, as it
results in an ugly experience for site users. PHP offers a more elegant alternative with which
you can define a custom function and nominate it for handling the errors.
A cookie is often used to identify a user. A cookie is a small file that the server embeds on
the user's computer. Each time the same computer requests a page with a browser, it will
send the cookie too. With PHP, you can both create and retrieve cookie values.
Create Cookies With PHP
Sessions:
A session is a way to store information (in variables) to be used across multiple pages.
When you work with an application, you open it, do some changes, and then you close it.
This is much like a Session. The computer knows who you are. It knows when you start the
application and when you end.