php嵌入html
<?php
function outputMyName($fname) {
echo "我的名字叫 ";
echo "周 ".$fname."<br />";
}
?>
<html>
<body>
<?php
outputMyName("胜超");
outputMyName("宇恒");
outputMyName("宇盟");
?>
</body>
</html>
结果如下:
我的名字叫 周 胜超
我的名字叫 周 宇恒
我的名字叫 周 宇盟
相关文档:
1. $_GET
:
http://localhost/a.php?a=ok
<?
echo
$_GET['a']; //显示"ok"
?>
2. $_SERVER['QUERY_STRING']
http://localhost/a.php?a=1&b=2&c=3
......
下面介绍几种PHP中判断、循环的几种写法。
最普通的判断:
<?php
if( $args != NULL )
{
call_func($args);
}
?>
对于单行的执行语句,可以写成:
<?php
if( $args != NULL ) call_func($args);
?>
也可以使用引号的方式。
<?php
if( $args != NULL ):
call_func($args);
......
1. 安装php5.1以上的版本,有支持pdo!为了使你的环境能提供对pdo的支持!在php.ini文件加入以下:
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_pdo_mssql.dll(支持mssql数据库)
2. 以下为PH中PDO的具体使用
<?php
$dsn = 'mysql:dbname=MyDbName;host=localhost';
$user = 'root';
......
<?php
define('SMARTY_TMP_DIR','C:/php5/Smarty-2.6.13/');
define('SMARTY_DIR','C:/php5/Smarty-2.6.13/libs/'); //SMARTY_DIR ->smarty keyword,must be defined as libs dectory
require_once(SMARTY_DIR.'Smarty.class.php');
//建立一个smarty对象
$smarty = new Smarty;
$smarty->template_dir = ......
Code:
<?php
function genRandomString($len)
{
$chars = array(
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K", "L", "M", "N", "O", ......