25.09.2014 Views

ZEND PHP 5 Certification STUDY GUIDE

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Object Oriented Programming in <strong>PHP</strong> ” 135<br />

} catch (ReflectionException $e) {<br />

// ...<br />

}<br />

$prototype = $func->name . ’ ( ’;<br />

$args = array();<br />

foreach ($func->getParameters() as $param) {<br />

$arg = ’’;<br />

if ($param->isPassedByReference()) {<br />

$arg = ’&’;<br />

}<br />

if ($param->isOptional()) {<br />

$arg = ’[’ .$param->getName(). ’ = ’ .$param->getDefaultValue(). ’]’;<br />

} else {<br />

$arg = $param->getName();<br />

}<br />

$args[] = $arg;<br />

}<br />

$prototype .= implode(", ", $args) . ’ )’;<br />

echo "$prototype";<br />

echo "<br />

<br />

Comment:<br />

<br />

<br />

" .$func->getDocComment(). "<br />

<br />

<br />

File: " .$func->getFileName(). "<br />

<br />

Lines: " .$func->getStartLine(). " - " .$func->getEndLine(). "<br />

";<br />

}<br />

Licensed to 482634 - Amber Barrow (itsadmin@deakin.edu.au)<br />

?><br />

This simple code runs through every single user-defined function in our script and<br />

extracts several pieces of information on it; its output will look similar to the following:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!