This post covers the Encoding section of the Strings chapter when studying for the Zend PHP 7 Certification.
There are a variety of PHP extensions that support character encoding. The Multibyte String extension provides string functions that help you deal with multibyte encodings. mbstring is a non-default extension. This means it is not enabled by …
This post covers the PCRE section of the Strings chapter when studying for the Zend PHP 7 Certification.
The PCRE (Perl Compatible Regular Expression) library is one that can contains functions that implement regular expression patterns.
When using the PCRE functions, it is required that the pattern is enclosed by delimiters.
Often used delimiters are …
This post covers the Formatting section of the Strings chapter when studying for the Zend PHP 7 Certification.
A number of functions are available in PHP that assist with formatting a string, such as printf and sprintf to name a couple of commonly used ones.
The printf() function outputs a formatted string. There is no …
This post covers the Replacing section of the Strings chapter when studying for the Zend PHP 7 Certification.
Some of the string functions for replacing characters in a given string can be seen below.
The str_replace function replaces all occurrences of the search string with the replacement string. It can take up to four parameters.
This post covers the Searching section of the Strings chapter when studying for the Zend PHP 7 Certification.
Some of the string functions for searching characters in a given string can be seen below.
The strpos() function finds the position, starting from zero, of the first occurrence of a substring in a string. The function …
This post covers the Extracting section of the Strings chapter when studying for the Zend PHP 7 Certification.
Some of the string functions for extracting characters in a given string can be seen below.
The substr() function returns part of a string. It takes three parameters.
String – The input string that must be …
This post covers the Matching section of the Strings chapter when studying for the Zend PHP 7 Certification.
There are a variety of functions in PHP we can use to compare and match two strings. Equal comparison operators used to compare if two strings are equal.
$string1 = ‘string’;
$string2 = ‘something else’;
var_dump($string1 …
This post covers the Quoting section of the Strings chapter when studying for the Zend PHP 7 Certification.
A string literal can be specified in different ways.
Single quoted
Double quoted
HEREDOC/NOWDOC, which can be seen here
Single quoted strings will display things almost completely “as is.” Variables and most escape sequences will …
This post covers the HEREDOC & NOWDOC section of the Strings chapter when studying for the Zend PHP 7 Certification.
HEREDOC
The heredoc syntax uses the operator: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.
<?php
$string …