الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طلب شرح بعض الاكواد التي لم افهمها

بدأه خليل إبراهيم في 14 يناير 2009 · 2 رد · 775 مشاهدة · في منتدى تطوير المواقع بـ PHP
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

اثناء لتصفحى لموقع انجلزي لتعلم php وجدت بعض الاكواد لم افهم لماذا هي او ما فائدتها الصق لكم الشرح كعلني اجد مفهومها

PHP - String Creation Double-Quotes

We have used double-quotes and will continue to use them as the primary method for forming strings. Double-quotes allow for many special escaped characters to be used that you cannot do with a single-quote string. Once again, a backslash is used to escape a character.

PHP Code:

$newline = "A newline is \n";
$return = "A carriage return is \r";
$tab = "A tab is \t";
$dollar = "A dollar sign is \$";
$doublequote = "A double-quote is \"";

Note: If you try to escape a character that doesn't need to be, such as an apostrophe, then the backslash will show up when you output the string.

These escaped characters are not very useful for outputting to a web page because HTML ignore extra white space. A tab, newline, and carriage return are all examples of extra (ignorable) white space. However, when writing to a file that may be read by human eyes these escaped characters are a valuable tool!

ماذا فائدة هذا الكود

PHP Code:

$newline = "A newline is \n";
$return = "A carriage return is \r";
$tab = "A tab is \t";
$dollar = "A dollar sign is \$";
$doublequote = "A double-quote is \"";

انا اعلم انها متغيرات لكن ما فائدة

\n

\r

\t

\$

\"

التي مكتوبه بالكود

#2

بشكل عام \ هو محرف هروب:

\n سطر جديد

\r سطر جديد عند طباعة المستند في الطابعة

\t تاب أي أربع محارف فارغة

\$ إشارة $ في php هي من قواعد اللغة ولايمكن طباعتها على الشاشة إلا إذا سبقته ب \ وإلا سيعطي مدقق اللغة خطأ

\" أيضاً " أيضاً لطباعة " فال \ هو فقط لإخبار المدقق بأن يتجاهل المحرف الذي بعده

#3

جزيت خيرا

مواضيع مشابهة