These functions all manipulate strings in various ways. Some more specialized sections can be found in the regular expression and URL handling sections.
Before you can use a string you have to create it! A string can be used directly in a function or it can be stored in a variable. Below we create the exact same string twice: first storing it into a variable and in the second case we send the string directly to echo.
Sample Code:
<?php
$string = "This was sample of string";
echo "This was inside of echo"
echo $string;
?>
Occasionally, the string of the code will printed and the output look like this:
Output:
This was sample of string This was inside of echo
PHP - String Creation Single Quotes
In output we created, the file was created using a double quotes, but its just a correct to create a string using single quotes, otherwise the string will do print only a single quotes. It look like this,Sample Code:
<?php
$string = 'This was sample of string';
echo 'This was sample 2 of string';
echo $string;
?>
Output:
This was sample of string This was sample 2 of string
PHP - String Creation Heredoc
The two methods above are the traditional way to create strings in most programming languages. PHP introduces a more robust string creation tool called heredoc that lets the programmer create multi-line strings without using quotations. However, creating a string using heredoc is more difficult and can lead to problems if you do not properly code your string! Here's how to do it:<?php
$string = <<<TEST
This is web developer it will print you the sample string
TEST;
echo $string;
?>
Output:
This is web developer it will print you the sample stringThere are a few very important things to remember when using heredoc.
- Use <<< and some identifier that you choose to begin the heredoc. In this example we chose TEST as our identifier.
- Repeat the identifier followed by a semicolon to end the heredoc string creation. In this example that was TEST;
- The closing sequence TEST; must occur on a line by itself and cannot be indented!
Reference: Tizag.com
A string is a series of characters. There are exactly 256 different characters possible. The present stable versions of PHP - PHP4 and PHP5, have no native support for Unicode (Unicode will be supported in the forthcoming PHP6). There aren't string length limitations in PHP except the server's available memory and the configuration of the php.ini settings file. A string is a series of characters. There are exactly 256 different characters possible. The present stable versions of PHP - PHP4 and PHP5, have no native support for Unicode (Unicode will be supported in the forthcoming PHP6). There aren't string length limitations in PHP except the server's available memory and the configuration of the php.ini settings file.
Hello,
TumugonBurahinNice blog i like it
Over past few years, an ultra rapid constant growth seen in the World Wide Web across the globe. In fact, the emergence of powerful web applications and Content Management Systems such as Zen Cart, Drupal, WordPress, Joomla, Magento, osCommerce, Modx etc.,