This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet13/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   9   10   11   12   13   14   15   16   ...   69
Bog'liq
PHP

Lexical Structure
|
19
Comments
Comments give information to people who read your code, but they are ignored by
PHP. Even if you think you’re the only person who will ever read your code, it’s a
good idea to include comments in your code—in retrospect, code you wrote months
ago can easily look as though a stranger wrote it.
Good practice is to make your comments sparse enough not to get in the way of the
code itself and plentiful enough that you can use the comments to tell what’s hap-
pening. Don’t comment obvious things, lest you bury the comments that describe
tricky things. For example, this is worthless:
$x = 17; // store 17 into the variable $x
whereas this may well help whoever will maintain your code:
// convert &#nnn; entities into characters
$text = preg_replace('/&#([0-9])+);/e', "chr('\\1')", $text);
PHP provides several ways to include comments within your code, all of which are bor-
rowed from existing languages such as C, C++, and the Unix shell. In general, use C-
style comments to comment
out
code, and C++-style comments to comment
on
code.
Shell-style comments
When PHP encounters a hash mark (
#
) within the code, everything from the hash mark
to the end of the line or the end of the section of PHP code (whichever comes first) is
considered a comment. This method of commenting is found in Unix shell scripting
languages and is useful for annotating single lines of code or making short notes.
Because the hash mark is visible on the page, shell-style comments are sometimes
used to mark off blocks of code:
#######################
## Cookie functions
#######################
Sometimes they’re used before a line of code to identify what that code does, in
which case they’re usually indented to the same level as the code:
if ($double_check) {
# create an HTML form requesting that the user confirm the action
echo confirmation_form( );
}
Short comments on a single line of code are often put on the same line as the code:
$value = $p * exp($r * $t); # calculate compounded interest
When you’re tightly mixing HTML and PHP code, it can be useful to have the clos-
ing PHP tag terminate the comment:
Then another
Then another 4
,ch02.15294 Page 19 Wednesday, March 13, 2002 11:42 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Download 6,9 Mb.

Do'stlaringiz bilan baham:
1   ...   9   10   11   12   13   14   15   16   ...   69




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish