php的功能和原理:在前台页面php(服务器php.exe解析的脚本语言写的)进行服务器请求时,服务器获取到后,交给php.exe进行解析处理后,将解析的html脚本通过apache服务器返回给前台浏览器,浏览器展示出html构成的页面供给大家看。
<?php
$title='2019';
define('ST_NAME', 'NAMEE'); //可以运算,类里不支持define
const STT='1111'; //不能运算,类里可以用的常量
$tablename=ST_NAME.'哈迪';
$tablename='<a href="">'.ST_NAME.'</a>'.'哈迪';//常量在变量中
$user=[1,'诸葛',30,'男','@111','121212'];
echo '<pre>';
print_r($user);
$uu=[
'id'=>1,
'name'=>'啊',
'age'=>12,
'sex'=>'男',
'email'=>'@111',
'password'=>'122'
];
foreach ($uu as $key => $value) {
echo $key."值是".$value.'<br>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?=$title?></title>
</head>
<body>
<table>
<caption><?=$title ?></caption>
<thead>
<tr>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
</tr>
</thead>
<tbody>
<?php
echo '<tr>';
echo '<td>1</td>';
echo '<td>2</td>';
echo '<td>3</td>';
echo '<td>'.$uu['id'].'</td>';
echo '</tr>';
?>
</tbody>
</table>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号