PHP TUTORIALS - PHP Strings
PHP Strings
ADVERTISEMENTS
$string_1 = "This is a string in double quotes";
$string_2 = "This is a somewhat longer, singly quoted string";
$string_39 = "This string has thirty-nine characters";
$string_0 = ""; // a string with zero characters
|
ADVERTISEMENTS
<?
$variable = "name";
$literally = 'My $variable will not print!\\n';
print($literally);
$literally = "My $variable will print!\\n";
print($literally);
?>
|
ADVERTISEMENTS
My $variable will not print!\n
My name will print
|
String Concatenation Operator
<?php
$string1="Hello World";
$string2="1234";
echo $string1 . " " . $string2;
?>
|
Using the strlen() function
<?php
echo strlen("Hello world!");
?>
|
Using the strpos() function
<?php
echo strpos("Hello world!","world");
?>
|