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.

88 ” Strings And Patterns<br />

b<br />

c<br />

d<br />

e<br />

u<br />

f<br />

F<br />

o<br />

s<br />

x<br />

X<br />

Output an integer as a Binary number.<br />

Output the character which has the input integer as its ASCII value.<br />

Output a signed decimal number<br />

Output a number using scientific notation (e.g., 3.8e+9)<br />

Output an unsigned decimal number<br />

Output a locale aware float number<br />

Output a non-locale aware float number<br />

Output a number using its Octal representation<br />

Output a string<br />

Output a number as hexadecimal with lowercase letters<br />

Output a number as hexadecimal with uppercase letters<br />

Here are some simple examples of printf() usage:<br />

$n = 123;<br />

$f = 123.45;<br />

$s = "A string";<br />

printf ("%d", $n); // prints 123<br />

printf ("%d", $f); // prints 123<br />

// Prints "The string is A string"<br />

printf ("The string is %s", $s);<br />

// Example with precision<br />

printf ("%3.3f", $f); // prints 123.450<br />

// Complex formatting<br />

function showError($msg, $line, $file)<br />

{<br />

return sprintf("An error occured in %s on ".<br />

"line %d: %s", $file, $line, $msg);<br />

}<br />

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

showError ("Invalid deconfibulator", __LINE__, __FILE__);

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

Saved successfully!

Ooh no, something went wrong!