最好的办法是获得一个具有语法高亮功能的优秀代码编辑器,它是专为 PHP 编码而构建的。
但这里有一些基础知识:
<?php
/*Standard Variable--
Anything placed between quotes is treated as a string.
A string quote must start and end, you can continue a string but that block
must also have a start and end quote.
*/
$variable_name = "Value";
//or
$variable_name = 'Value';
//If you have a line of html with lots of double quotes, its sometime easyier to use single quotes
$variable_name = '<a style="cursor: pointer; onClick=fetchAlbum("'.$values['aid'].'") class="photo-gallery-album-thumbs-title"'.$values['name'].'")>';
//Or you have to escape the quotes or replace them with single
$variable_name = "<a style=\"cursor: pointer; onClick=fetchAlbum(\"".$values['aid']."\") class=\"photo-gallery-album-thumbs-title\"".$values['name']."\")>";
//You can also use curly brackets on double quotes but you cant use them on single
$variable_name = "<a style=\"cursor: pointer; onClick=fetchAlbum(\"{$values['aid']}\") class=\"photo-gallery-album-thumbs-title\"{$values['name']}\")>";
//Also you cant put carriage returns or tabs ect in single quotes
$variable_name = "\tSome value\r\n";
//tho yo can do
$variable_name = "\t".'Some value'.PHP_EOL;
//Using double quotes for variable assignment or printing is slower then single quotes
//Concatenation
$variable_name = "v"."a"."l"."u"."e";
//variable continuing
$variable_name .= "value";
//simple echoing out
echo 'Some value';
echo "Some value";
echo $variable_name;
print "Some value";
//or you can break out of php and put your html
?>