PHP - ข้อมูลชนิดอักขระ (String) |
|
Written by admin
Sunday, 20 June 2010 20:58
|
|
ตัวอย่างโค้ดการต่อสตริง หรือ ต่อข้อความ ด้วยภาษา php ในรูปแบบต่าง ๆ <? // แสดงข้อแตกต่างระหว่าง single quoted และ double quoted // แต่ถ้าใช้ double qouted (") หรือ 2 ขีด การขึ้นบรรทัดใหม่จะทำตามตัวอย่างข้างล่างนี้ค่ะ echo "You can also have embedded newlines in "; echo "strings this way as it is "; echo "okay to do<br><br>"; // Outputs: Arnold once said: "I'll be back" echo 'Arnold once said: "I\'ll be back"<br>'; echo"Arnold once said: \"I'll be back\"<br><br>"; // Outputs: You deleted C:\*.*? echo 'You deleted C:\\*.*?<br>'; echo 'You deleted C:\*.*?<br>'; echo "You deleted C:\\*.*?<br><br>"; // Outputs: This will not expand: \n a newline echo 'This will not expand: \n a newline<br>'; echo "This will not expand: \\n a newline<br><br>"; // Outputs: Variables do not $expand $either echo 'Variables do not $expand $either<br>'; echo "Variables do not \$expand \$either<br><br>"; ?> ผลลัพธ์ ทดสอบการแสดงสัญลักษณ์พิเศษ ทดสอบการแสดงสัญลักษณ์พิเศษ You can also have embedded newlines in strings this way as it is okay to do You can also have embedded newlines in strings this way as it is okay to do Arnold once said: "I'll be back" Arnold once said: "I'll be back" You deleted C:\*.*? You deleted C:\*.*? You deleted C:\*.*? This will not expand: \n a newline This will not expand: \n a newline Variables do not $expand $either Variables do not $expand $either
<? $a = "webmaster"; echo "ฉันเป็น ".$a." www.ban-goi.com"; ?> ผลลัพธ์
|