print_r
$_var
$var_1
<?php
$_var = 1;
print "this is $_var";
print "i say \"hehe\"!";
print "<a> hehe \" haha \" $_var '$_var' </a>";
?>
<form action="a.php" method="post">
<p>Name: <select name="title">
<option>
...
<option>
</select></p>
</form>
《a.php》
<?php
$title = $_POST['title'];
print "<p> $title";
?>
http://*.*.*.*/a.php?name=1
<?php
$var_name = $_GET['name'];
print "$var_name";
?>
<?php
$a = "a";
$b = "b";
$c =$a . $b;
$c = "$a$b";
?>
<?php
$posting = nl2br($_POST['posting']);
print "<p>$posting</p>";
nl2br()
?>
htmlspecialchars()
htmlentities()
strip_tags()
<?php
$html_post = htmlentities($_POST['posting']);
$strip_post = strip_tags($_POST['posting']);
print "<p>$posting</p>
<p>$html_post</p>
<p>$strip_post</p>"
?>
$urlencode()
<?php
$name = urlencode($name);
$email = urlencode($_POST['email']);
print "<a href=\"thanks.php?name=$name&email=$email \">";
?>
crypt()
mcrypt_encrypt() mcrypt_decrypt()
strtok()strcmp()strnatcmp()strcasecmp()strnatcasecmp()strstr()strpos()
str_word_count()substr()
str_ireplace()ucfirst()ucwords()strtoupper()strtolower()
<?php
if ($OK) {
} elseif($OTHER) {
}else {
}
switch ($var) {
case "$val1":
break;
default:
break;
}
for ($i = 1; $i <=31; $i++) {
}
while ($OK) {
}
do {
} while ($OK);
?>
empty()isset()is_numeric()
<?php
$list = array('1','2');
$list2 = array (
1 => 'a',
2 => 'b'
);
$list2[1] = 'z';
unset($list2[1]);
$listlist = array (
'list' => $list,
'list2' => $list2
);
sort($list);
rsort($list2);
?>
本文介绍了PHP编程中常用的变量操作、字符串处理、条件循环结构、数组管理等基本语法,并展示了如何通过内置函数来提高代码的安全性和用户体验。
1359

被折叠的 条评论
为什么被折叠?



