Home
Add Document
Sign In
Create An Account
PHP + MySQL + XML
Recommend Documents
No documents
PHP + MySQL + XML
Download PDF
32 downloads
108240 Views
5MB Size
Report
Comment
Apache Mysql PHP ... .... placeholder=”
[email protected]
" />.
PHP + MySQL + XML Alexander O’Connor
• • • • • • • • • • •
Brief introduction to PHP Variables Flow Control Basic Forms Arrays Functions & imports Connecting to Databases Sessions Security SimpleXML File I/O
1 2 3
Background
LAMP Linux (or Other OS) Apache
Mysql
PHP
Basic Syntax
$ indicates a variable $name is a variable called name
= assigns the value ‘Sam’ to $name
We can use a variable in place of a value such as a string. In this case, we print out ‘Sam’
PHP variables have implicit type Types include:
• • • • • • • •
Booleans Integers Floating point numbers Strings Arrays Objects Resources NULL PHP will try to ‘juggle’ types to get the right one in context.
Operators $a + $b
Add the values of $a and $b
$a * $b
Multiply the values of $a and $b
$a - $b
Subtract the value of $b from $a
$a / $b
Divide the value of $a by $b
$a % $b
Divide $a by $b and return the remainder (modulo)
. Is the concatenation operator, it adds strings together. Could also write echo “Hello, $name” with double quotes (interpolation).
Flow Control
Operator
Meaning
$a == $b
Equality (note double =)
$a != $b
Inequality (NOT equal)
$a < $b
Less than
html forms
html form
Data from form
User
PHP script
email address
html forms text
Plain text
password
Obfuscated text (****)
textarea
Editable text box
checkbox
On/off box
radio
Radio Buttons (pick one of a list)
select
Drop-down list
file
File upload
hidden
Add hidden data
html5 (partial) autofocus
Highlight this first
required
Browser checks for value
email
Browser checks for email
number
Browser checks for number
url
Browser checks for web address
Arrays
$name
Alex username
$_GET
Alex
check true
$array
$array
A
B
1
2
0
1
1
2
1
2
3
array_push
Push a new value onto the end of the array
array_pop
Pop the last value off the array
natsort
Sort the array by values, in a ‘natural order’
shuffle
Randomize the array
array_unique
Remove duplicates
reverse
Reverse the order of the array
print_r($array)
Pretty-print the array
Summary
PHP
Variables
• Inline with html • • statement ; • // comment • /* comment */
Forms • • text • password • html5 input • number • email • • $_GET[] or $_POST[]
• Store values • $variable_name • $x = 9; • Type Juggling • “$interpolation ” • ‘con’.‘cat’.‘enate’
Flow control • if () { } • elseif {} • else {} • while () {} • switch (value) { • case val : • break; • } Arrays
• $array[‘key’] • array functions • sort • reverse • shuffle • array_push • array_pop • foreach ($array as $key => $val)
• • • • • • • • • • •
Brief introduction to PHP Variables Flow Control Basic Forms Arrays Functions & imports Connecting to Databases Sessions Security SimpleXML File I/O
1 2 3
Picture Credits • Wheels of Industry no .1 http://www.sxc.hu/photo/447579 • Boxes and Bike http://www.sxc.hu/photo/78885 • Keyboard Spy http://www.sxc.hu/photo/754170 • Rasmus Lerdorf http://en.wikipedia.org/wiki/Rasmus_Lerdorf • Sleep tight http://www.sxc.hu/photo/682369 • Form http://www.sxc.hu/photo/478224 • Rusted Chain http://www.sxc.hu/photo/319183
Useful Links • Language Manual – http://www.php.net/manual/en/
• PHP Tutorials – http://devzone.zend.com/article/627 – http://phptutorial.info/ – http://www.tizag.com/phpT/
• Frameworks – Codeigniter http://codeigniter.com/ – List of Libraries http://komunitasweb.com/2009/03/20great-php-library-you-need-to-know/
Interesting Links • http://thenextweb.com/insider/ 2011/08/06/20-years-ago-today-the-worldwide-web-opened-to-the-public/
×
Report "PHP + MySQL + XML"
Your name
Email
Reason
-Select Reason-
Pornographic
Defamatory
Illegal/Unlawful
Spam
Other Terms Of Service Violation
File a copyright complaint
Description
×
Sign In
Email
Password
Remember me
Forgot password?
Sign In
Our partners will collect data and use cookies for ad personalization and measurement.
Learn how we and our ad partner Google, collect and use data
.
Agree & close