Write string in php

Page 1

Write String in PHP Write String in PHP - String is a collection of characters. In PHP, characters are equal to bytes, where there are 256 characters. PHP does not support native-unicode. To write a string in PHP, can use 3 (three) ways, namely by:   

single quoted - single quotes (') double quoted - double quotes (") heredoc syntax

For easier understanding of strings in php. Here is an example of string writing in php on a program. Program 1 File Name: string01.php Description: Program string with single quoted ('). Open notepad, then type this php code. <?php echo 'this is a simple string'; echo 'You can also have embedded newlines in strings this way as it is okay to do'; // Outputs: Arnold once said: "I'll be back" echo 'Arnold once said: "I\'ll be back"'; // Outputs: You deleted C:\*.*? echo 'You deleted C:\\*.*?'; // Outputs: You deleted C:\*.*? echo 'You deleted C:\*.*?'; // Outputs: This will not expand: \n a newline echo 'This will not expand: \n a newline'; // Outputs: Variables do not $expand $either echo 'Variables do not $expand $either'; ?>

Save it to the htdocs folder named string01.php. To see the result open the browser type http://localhost/string01.php in the address bar then enter.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.