PHP is a programming language that can be included on webpages and interpreted by the webserver as the page is assembled. The page is delivered to the browser with the PHP already interpreted – so the View Source feature within the browser is unable to see the original PHP code, only the resulting content and HTML/CSS/Javascript. PHP is generally included within blocks of code on a webpage, within special php tags. There are many reasons to use PHP, including:
- assemble static information on a webserver (server-side includes)
- retrieve and assemble data from a database to publish on a webpage
- calculate new information based on static or retrieved data
PHP Semantics
PHP as a programming language uses language structures very similar to many other Object Oriented programming languages -
- variables – boolean, float, integer, string, array, object, resource, NULL Dreamweaver is a weakly-typed programming language , no specifications are required. variable names begin with $ and contain no hyphens. variables are scoped and can only be referenced within the scope in which they are defined.
- operators – assignment = arithmetic + strings – the join operator . reassignment operator shortcuts +=
- conditionals – if statement, comparitive operators: == != > <
multiple conditions – the logical operators: && || ! - loops – for & foreach do while statements
- functions – php builtin functions and custom functions
- classes (objects) & resources: the -> operator access the properties and methods of an object. the date() object.
- escape characters. Precede with backslash. Escape characters needed for single quotations are single quote and apostrophe. Escape characters within double quotations are “nrt${}[].
$_GET & $_POST | Superglobal associative arrays
Two options for retrieving form submission values and other data. Option is generally set in a method attribute of the form tag. GET exposes data as query strings appended to the URL. POST transmits data in the background and can handle larger volumes of data, but there is no permalink to the view. Both methods create superglobal associative arrays of the user generated data.
Server-side Includes
Built in functionality in PHP with the include() functions. The include file can be html or php and only the markup – no document information or head section. php include files MUST have the php tags even though the include statement is also within php tags. php functions defined externally must be included BEFORE they are called in the code. references to php files MUST be relative.
- include – the external file is optional
- include_once – use when defining a function or class include file
- require – the external file is required
- require_once – use when defining a function or class include file
Hi, I don’t know how to move MySQL up to the remote server and make sure it is connected to my site?
First, you need to make sure that you haven’t done this before.
If not, then on Mac OSx run Applications->Utilities->Terminal
at the prompt type “ssh@tboyle@student.santarosa.edu” (without the double quotes)
at the prompt, enter your password (same as your ftp password)
at the next prompt enter “sudo sqlme”
you will get a page of information on the Terminal screen – accounts and passwords and a database name – save this information.
quit and exit from Terminal, that is it.