Archive for the 'PHP' Category

How to identify the file extension of an uploaded file PHP

Wednesday, November 11th, 2009

$ext = strtolower(substr(strrchr($file[’name’], ‘.’), 1));

Configuring upload limits in php.ini

Wednesday, December 10th, 2008

Try these:

post_max_size = 16M
upload_max_filesize = 16M
memory_limit = 16M

(memory_limit only affects this if you have configured
php with –enable-memory-limit)

vi /etc/php.ini

PHP Arrays

Monday, November 10th, 2008

Initialise a blank array and feed it some values.

$b = array();
$b[] = ‘a’;
$b[] = ‘b’;
$b[] = ‘c’;

Particularly useful if you want to loop over some database results and add to the array.

PHP Output array to page

Wednesday, September 24th, 2008

Simple technique to output a php array (in an easy to read style) to a page:

#foreach ($_GET as $key => $value) {
# echo “key=”.$key.” —— value=”.$value;
#}

foreach ($_POST as $key => $value) { echo ‘key=’.$key.’ - value=’.$value.’
‘; }

Creating PDFs

Thursday, September 4th, 2008

Sitepoint article

http://www.sitepoint.com/article/generate-pdfs-php/

PDF Lib

http://www.pdflib.com/download/

Difference between include and require && include_once and require_once

Wednesday, April 30th, 2008

 Difference between require() and require_once():  require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page).
So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don’t include the file more times and you will not get the “function re-declared” error.

Difference between require() and include() is that require() produces a FATAL ERROR if the file you want to include is not found, while include() only produces a WARNING.

There is also include_once() which is the same as include(), but the difference between them is the same as the difference between require() and require_once().

Simple postcode validation

Friday, February 22nd, 2008

Nice function:

http://snipplr.com/view/3152/postcode-validation/

Installing MySQL and PHP and Apache

Tuesday, February 6th, 2007

Best way is to simply use yum.

Yum install name of software

Thats it.