PHP Best Practices PowerPoint Presentation, PPT - DocSlides Slideshow

Download this presentationClick below link (As may be) to get this presentation.

PHP Best Practices PowerPoint Presentation, PPT - DocSlides

DownloadNote - The PPT/PDF document "PHP Best Practices PowerPoint Presentat..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

If there is code in more than one language in one file, short open tags may lead to confusion of parsers

Use

<?php

instead

Slide7

Exceptions

Handling exceptions and warnings is cool but dangerousIf exceptions are misused may lead to more problems that solveUse only when really neededExceptions may leak memoryThe memory, allocated for the for-loop does not get freed

for ($

i

= 10000; $

i

> 0; $

i

–-)

throw new Exception ('I Leak Memory!');

Slide8

Being E_STRICT

A lot of functions are being deprecatedIn PHP 5 using certain functions will raise E_STRICT errorIn PHP 6 those will become E_FATALExample:Function is_a is deprecatedUse instanceof instead

if (is_a($obj, 'FooClass')) $obj->foo();

if ($

obj

instanceof

'

FooClass

')) $

obj

->foo();

Slide9

Source Documentation

phpDocumentor tags are similar to Javadoc

Standard for generating documentation

Describes functions and classes, parameters and return values

Tools use them to generate code-completion, technical documentation and others