ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: PHP :: PHP Óï·¨

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

PHP
WINDOWSϰ²×°MyS..
PHP ÖÆ×÷ ÍøÕ¾/·þ..
ÓÃPHPºÍCSSÖÆ×÷»î..
PHP µ¥¼þģʽ
PHP MVCģʽ£¬Àà·..
PHP ÖÐʹÓÃÕýÔò±í..
PHP ·ÀÖ¹ SQL ×¢È..
PHP ¿çÕ¾µã½Å±¾¹¥..
PHP ·ÀÖ¹Óû§²Ù×Ý..
PHP ·ÀÖ¹Ô¶³Ì±íµ¥..

PHP Óï·¨


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ÐÞ¸Ä:2007-06-24 ä¯ÀÀ:8248 :: ::

You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
Äã²»ÄÜÖ±½Óͨ¹ýä¯ÀÀÆ÷Öеē²é¿´Ô´Îļþ[View sourse]”À´ä¯ÀÀPHPÔ´´úÂë —— ÄãÖ»ÄÜ´Óä¯ÀÀÆ÷»ñÈ¡PHPÎļþµÄ“HTMLÊý¾ÝÁ÷”¸ñʽµÄ½á¹û¡£ÕâÊÇÒòΪ·þÎñÆ÷ÊÇÊÂÏȽ«½Å±¾Ö´ÐÐÍê±ÏÒÔºóÔÙÒÔHTMLÊý¾ÝÁ÷µÄÐÎʽ´«»Øä¯ÀÀÆ÷µÄ£¬ËùÒÔÄã¿´µ½µÄÖ»ÄÜÊÇ´¦ÀíÍê±ÏÒÔºóµÄ½á¹û¡£


Basic PHP Syntax
PHP»ù±¾Óï·¨

A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.
PHP½Å±¾´úÂë¶Î£¨scripting block£©ÒÔ<?php Ϊ¿ªÊ¼²¢ÒÔ ?> ½áÊø¡£Ò»¸öPHP½Å±¾´úÂë¶Î¿ÉÒÔ±»·ÅÖÃÔÚÎļþÖеÄÈÎÒâλÖá£

On servers with shorthand support enabled you can start a scripting block with <? and end with ?>.
ÔÚ·þÎñÆ÷ÉÏÁíÒ»ÖÖÏà¶Ô¼ò±ãµÄÊéд·½·¨ÊÇ£ºÒÔ <? Ϊ¿ªÊ¼²¢ÒÔ ?> ½áÊø¡£

However, for maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.
È»¶ø£¬ÎªÁË·¢»ÓËü×î´óµÄ¼æÈÝÐÔ£¬ÎÒÃǽ¨ÒéʹÓñê×¼µÄÊéд·½Ê½£¨<?php£©¶ø²»ÊÇÉÏÊöÄÇÖÖ¼ò±ãµÄд·¨£¬¾ßÌåÈçÏ£º

<?php
?>

A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.
Ò»¸öPHPÎļþͨ³£°üº¬HTML±êÇ©£¬ÀàËÆÓÚHTMLÎļþ£»µ±È»£¬Ëü»¹°üº¬½Å±¾´úÂë¡£

Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser:
ͨ¹ýÏÂÃæµÄ´úÂ룬ÎÒÃÇ¿ÉÒÔÏòä¯ÀÀÆ÷·¢ËÍÒ»¶ÎÎı¾£º“Hello World!”

<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>

Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.
PHPÖеÄÿ¶Î´úÂëÐбØÐëÒԷֺŠ“;” ×öΪ½áÊøµÄ±êÖ¾£»·ÖºÅ“;”ÊÇÓÃÀ´Çø±ð²»Í¬Ö¸ÁîµÄ·Ö¸ô·û¡£

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".
¶ÔÓÚPHP¶øÑÔ£¬ÓÐÁ½ÖÖ·½·¨¿ÉÒÔÊä³öÎı¾½á¹û£ºecho ºÍ print¡£ÉÏÊöÀý×ÓÖУ¬ÎÒÃÇʹÓõÄÊÇ“echo”Ö¸Áî¡£


Comments in PHP
PHP×¢ÊÍ£¨ËµÃ÷£©Óï¾ä

In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.
ÔÚPHPÖУ¬ÎÒÃÇʹÓà “//” À´×¢Ê͵¥ÐÐÓï¾ä£¬Ê¹ÓÓ /* */ ”À´×¢ÊͶàÐÐÓï¾ä£¬¾ßÌåÈçÏ£º

<html>

<body>
<?php
//ÕâÊÇÌõ×¢ÊÍ
/*
ÕâÊÇ×¢ÊÍÓõÄ
Ò»´ó¿éÇøÓò
*/
?>
</body>
</html>

ÆÀÂÛ (0) All