Part 4 - Server side Handling data with PHP Flashcards
(136 cards)
An array that contains keys and values sent to the server on the end of the URL or by submitting a HTML form using the GET method.
describe the superglobal variable
$_GET
Basic syntax (arguments omitted):
define(name,value)
@param name (Required) Specifies the name of the constant
@param value (Required) Specifies the value of the constant.
describe the syntax and parameters of
define()
what are the syntax and parameters of
var_export()
Syntax:
var_export(variable,return);
@param variable (Required). Specifies the variable to check
@param return (Optional). If set to true, it returns the variable representation instead
of outputting it
describe the function
var_export()
a function that outputs or returns structured information about a variable.
describe the superglobal variable
$_GET
An array that contains keys and values sent to the server on the end of the URL or by submitting a HTML form using the GET method.
describe the function
define()
this function is used to define a constant
describe the syntax and parameters of
empty()
Syntax:
empty(variable);
@param variable (Required) Specifies the variable to check
function used for case insensitive comparison of two strings, returns 0 if the two strings match
describe the function
strcasecmp()
give 3 points that describe
Java
points on this include:
1.Open source
2.Object oriented
3.When used to serve dynamic web content a special web server is required such as Tomcat
describe the function
htmlspecialchars()
a function that converts some predefined characters to HTML entities.
describe the function
strcasecmp()
function used for case insensitive comparison of two strings, returns 0 if the two strings match
describe the
difference between declaring strings with single vs double quotes
Single quotes - these are interpreted exactly as written and so the text within the single quotes will always be unchanged
Double quotes - anything written within double quotes will be interpreted by PHP, this means if a variable name is included it will be evaluated and replaced by its value. Any other escape sequences will also be interpreted within double quotes
To implement this:
1.We set a flag in PHP files that will be requested by URL, the flag states that it is safe for files to run
a)This can be achieved setting a constant using define() function
2.Files that should only be executed via require or include will look for the flag, if it is not set then they will refuse to execute
a)This can be achieved by:
b)Checking if flag is set using the defined() function
c)If the flag is not set we terminate the script using the die() method
This ensures that users can only execute the scripts that we intend them to execute,
describe the implementation that would mitigate users executing the scripts that we will call using the require
and include
statements
this can be mitigated by cleaning text of any characters that could hold code before it is sent to the users browser.
we can accomplish this by using the function htmlspecialchars(). which replaces HTML characters with HTML entities
give one example of how a
Cross site scripting (XSS) attack can be mitigated
in PHP
when we access an array we should always check to see if it is empty.
the reason being because if we access an element that is not there then PHP will output a notice in the HTML. this should be hidden
when accessing an array what action should we perform first and why
these include:
1.Hypertext Preprocessor (PHP)
2.Active Server Pages.NET (ASP.NET)
3.Java
4.Python
5.Node.js
name 5
server side programming languages
Example:
$array = [];
if (!empty($array[‘id’])) {
Code if value exists;
} else {
Code if value does not exist;
}
give an example that checks if an array has content using an if…else statement
give an example that checks if an array has content using an if…else statement
Example:
$array = [];
if (!empty($array[‘id’])) {
Code if value exists;
} else {
Code if value does not exist;
}
using a for each loop write the syntax for extracting the key and value of the current element
syntax:
foreach ($array as $key => $value) { Code to execute; }
points on this include:
1.Open source
2.Object oriented
3.When used to serve dynamic web content a special web server is required such as Tomcat
give 3 points that describe
Java
sometimes known as a dictionary is an array with named keys and associated values for each key
describe an
Associative arrays
An array that contains data previously stored on the server in the current session
describe the superglobal variable
$_SESSION
how do we
declare a constant in PHP
this is accomplished by using the define() function
An array that contains keys and values sent to the server by submitting a HTML form using the POST method.
describe the superglobal variable
$_POST
The Cat got the cream
?> ```The Cat got the cream
?> ```