CPSC 431, Database and Applications, PHP, MySQL, Midterm
nl2br
Inserts HTML line breaks before all newlines in a string
implode
Join array elements with a string
what is str_replace?
This function returns a string or an array with the replaced values.
Are variables case sensitive?
True
Can there be more than 1 column in a primary key?
True
What is first step when querying a db from the web?
Validate user input
Is PHP case sensitive?
Variable names are case-sensitive but function names are not case sensitive
What is the function to create an array?
array()
what is ksort?
ascending order, according to key $list=array("key1"=>"value1");
what is asort?
ascending order, according to value$list=array("key1"=>"value1");
sort function sorts in what order?
ascending order, sort($list)
==
compare values
===
compares values and type
rsort functions sorts what order?
descending order, rsort($list)
What is @ used for? Use foo
error supression @foo
What can a PHP function contain
letters, digits, underscores
Is the default pass by value or pass by reference?
pass by value
What is the default access modifier?
public
What is the difference between require and include?
require generates an error if the file doesn't exist and include just warns if the file doesn't exists.
What are the sort functions?
sort, rsort, asort, ksort
sort
sorts an array
strtr, Hilla Warld -> Hello World
strtr("Hilla Warld", "ia", "eo");
Which quotation allows for string interpolation?
"
What is a try catch for?
For handling exceptions
chop
Alias of rtrim()
What is an update anomaly?
An update anomaly is a data inconsistency that results from data redundancy and a partial update.
Are functions case sensitive?
False
substr_compare
Compares two strings from a specified start position
CIA
Confidentiality, Integrity, Availability
htmlentities
Convert all applicable characters to HTML entities
htmlspecialchars
Convert special characters to HTML entities
strtoupper
Converts a string to uppercase letters
What does DSN stand for?
Data Source Name
preg_replace
Perform a regular expression search and replace
substr
Returns a part of a string
sort order flags
SORT_REGULAR - compare items normally SORT_NUMERIC - compare items numerically SORT_STRING - compare items as strings SORT_LOCALE_STRING - compare items as strings, based on the current locale. SORT_NATURAL - compare items as strings using "natural ordering" SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
What is wrong with this? select col1 from foo where $searchType = '$searchterm'
SQL injection attack
auto_prepend_file
Specifies the name of a file that is automatically parsed after the main file. The file is included as if it was called with the require function.
explode
Split a string by a string
datatypes
String Integer Float Boolean Array Object Resource Callable
strip_tags
Strip HTML and PHP tags from a string