CodesJava

Easy learning with example program codes

PHP Strings


A sequence of characters is called as string. In PHP, a string can be specified in four ways:

  • single quoted string
  • double quoted string
  • heredoc syntax string
  • newdoc syntax string

Single Quoted String:

A string enclosed in a single quote is called a single quoted string. Escape sequences and variables can not be interpreted using single quoted strings.

Double Quoted String:

A string enclosed in a double quote is called a double quoted string. Escape sequences and variables can be interpreted using double quoted strings.
Example 1: Variables inside a Single quoted string

<!DOCTYPE html>
<html>
<body>
 
<?php  
$num=100;   
$string='print $num';  
echo "$string <br/>";  
?>
 
</body>
</html>

Output

print $num

Example 2: Variables inside a Double quoted string

<!DOCTYPE html>
<html>
<body>
 
<?php  
$num=100;   
$string="print $num";  
echo "$string <br/>";  
?>
 
</body>
</html>

Output

print 100
Posted in PHP   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki