Nofollow

Example nofollow in a link <a href=”http://www.someurl.co.uk” target=”_blank” rel=”nofollow”>Some Text</a>

Read More

Getting URL Arguments

Get an argument GET only using $_GET POST only using $POST GET or POST using $_REQUEST Did GET or POST occur Example GET URL Start with an ‘?’, then separate other values with an ‘&’ To read: Example For POST Parameters Sanitise Them!!! htmlentities() converts things like < > ” \ etc into HTML strings like […]

Read More

Variables

Variables General Variable names must start with a ‘$’ character (to allow the php parser to work as fast as possible by instantly know it is a variable). A variable name must start with a letter of the alphabet or and underscore ‘_’. Variable names may only contain: ‘a’ – ‘z’, ‘A’ – ‘Z’ and […]

Read More

Redirect and Reload

Before outputting page content Note this must be before any html headers are sent (i.e. in php code before html output) Redirect to a new page Reload the current page The php header function Redirect with check you’re not already on target page If you’ve outputted some page content JavaScript method Using META tag method

Read More

Reading content from other web pages

Use CURL Do this $curl_connection= curl_init(‘http://mysite.com/index.php’); curl_setopt ($curl_connection, CURLOPT_POST, 1); curl_setopt ($curl_connection, CURLOPT_POSTFIELDS, “option=com_content&task=blogcategory&id=24&Itemid=55″); or do this $post_data[‘cmd’] = ‘_xclick’; $post_data[”] = ”; $post_data[”] = ”; $post_data[”] = ; $post_data[”] = ; $post_data[”] = ; $post_data[”] = ; foreach ( $post_data as $key => $value) { $post_items[] = $key . ‘=’ . $value; } $post_string […]

Read More

If

Logical OR Logical AND Not Equal When return value can be boolean or an integer Use if ($ReturnValue === false) or $ReturnValue !== false) If with load of a return value into a variable Ensure you enclose the assignment in brackets or it won’t work correctly

Read More

Sending Email

To send an email in php use the mail function Working example PHPMailer Great when you want to send email via a SMTP server (e.g. googlemail), attach files to emails, etcDownload from http://phpmailer.worxware.com/Copy class.phpmailer.php, class.pop3.php and class.smtp.php into your site (e.g. in a folder called phpmailer) and use one of their example files as the […]

Read More

Echo

Abbreviated way of inserting an echo in HTML “<?=” can be used in place of “<?php echo” Calling a function that can return an optional string within HTML Multiple Lines Note the END marker must appear at the start of the line with no whitespace Echo the contents of an array

Read More

PHP Defines

You can just create a variable to hold define values like this: But this is the PHP correct way to define: Define an array defined() (ifdef)

Read More

Date And Time

Getting Date and Time Elements Using the current DateTime Using a DateTime variable Parameters you can use Calculations Date in # days time Compare Date Time MYSQL Date & Time To set a DateTime field to now use: (Don’t add single quotes around it) Is String A DateTime? Convert DateTime See Strings-Values

Read More