الفصل السادس
(dot) . يمكن وصل النص بعلامة النقطة //
. + لا تستخدم علامة الجمع //
/* Assigning a string. */ $str = "This is a string";
echo " Result: ". $str. "<BR>";
/* Appending to it. */
$str = $str . " with some more text";
echo "Result: ". $str. "<BR>";
/* Another way to append, includes an escaped newline. */
#1
$str .= and a newline at the end.\n";
echo " Result: ". $str. "<BR>";
/* This string will end up being '<p>Number: 9</p>' */ $num = 9;
$str = "<p>Number: $num</p>";
echo "Result: ". $str. "<BR>";
/* This one will be '<p>Number: $num</p>' */ $num = 9;
$str = '<p>Number: $num</p>';
་
echo " Result: ". $str. "<BR>";
/* Get the first character of a string */
$str = 'This is a test.';
$first = $str[0];
echo " Result: ". $str. "<BR>";
echo "Result: ". $first. "<BR>";
/* Get the last character of a string. */ $str = 'This is still a test.';
$last = $str[strlen($str)-1];
echo "Result :
$str. "<BR>";
echo "Result: ". $last. "<BR>";
?>
متنوعات
۲۰۲
ص ٢٠٢