Week 9 - PHP Part 3 Flashcards
What are PHP Require and Include used for?
How are they different?
PHP Include is a function used for resuing PHP code such as menus.
Where include allows for the website to continue running, require means that it must be filled in otherwise there will be a fatal error and the website will crash.
How can we manage and maintain states between clients and servers?
Query strings, sessions and hidden fields.
State
The behaviour and interaction of a user during a web browser session.
Query Strings
A string of characters used to transfer data between PHP scripts to maintain state of a user.
They are found in the URL and have many parts to them which allow for specific information from a database to be received and allow this to work.
What do you need to pass information between websites using query strings?
- ? after the URL
- name = value pairs
- & separating the name = value pairs
Sessions
An amount of time where PHP script will maintain the state on a web server.
Why do we want to maintain state information?
It ensures that the user’s experience and usability of the website will be as streamline as possible.
For example: not having to re-enter in their details on every subpage of a webpage.
Why is query string passing used?
So that we can pass information between PHP scripts.
Was HTTP stateful or stateless?
HTTP was a stateless protocol until cookies were introduced which made them stateful.
Hidden Input
A hidden field in a form which allows for data to be stored without the user seeing it.
Typically used for storing database records which need to be updated when form in submitted.