Page 132 - Open Soource Technologies 304.indd
P. 132
Web Technologies-I
Notes 5. A ................ denoting the character to use to pad the results to the appropriate string size.
(a) type specifier (b) padding specifier
(c) null specifier (d) none of these
6. strip_tags( ) function use to
(a) remove HTML tags (b) add HTML tags
(c) both (a) and (b) (d) none of these
Fill in the blanks:
7. The ..................... function sends one value to the browser.
8. A regular expression follows a strict ..................... to describe patterns of characters.
9. The strops( ) function find the first ..................... of a small string in a larger string.
5.9 Summary
• The string in PHP is implemented as an array of bytes and an integer indicating the length
of the buffer. It has no information about how those bytes translate to characters, leaving
that task to the programmer.
• When you define a string literal using double quotes or a heredoc, the string is subject to
variable interpolation. Interpolation is the process of replacing variable names in the string with
the values of those variables. There are two ways to interpolate variables into strings—the
simple way and the complex way.
• Single-quoted strings do not interpolate variables. Double-quoted strings interpolate
variables and expand the many PHP escape sequences.
• The print ( ) function sends one value (its argument) to the browser. It returns true if the
string was successfully displayed and false otherwise. The printf( ) function outputs a
string built by substituting values into a template (the format string). It is derived from the
function of the same name in the standard C library.
• PHP has several functions for changing the case of strings: strtolower( ) and strtoupper
( ) operate on entire strings, ucfirst( ) operates only on the first character of the string, and
ucwords( ) operates on the first character of each word in the string.
• Most database systems require that string literals in your SQL queries be escaped. SQL’s
encoding scheme is pretty simple- single quotes, double quotes, NUL-bytes, and backslashes
need to be preceded by a backslash.
• Data often arrives as strings, which must be broken down into an array of values. For
instance, you might want to separate out the comma-separated fields from a string such as
“Ank, 25, Amr”.
5.10 Keywords
Interpolation: Interpolation is the process of replacing variable names in the string with the
values of those variables.
print ( ): The print ( ) function sends one value (its argument) to the browser. It returns true if the
string was successfully displayed and false otherwise.
printf( ): The printf( ) function outputs a string built by substituting values into a template (the
format string). It is derived from the function of the same name in the standard C library.
126 LOVELY PROFESSIONAL UNIVERSITY