Php

来自Shiyin's note
跳到导航 跳到搜索
  • 升级到fedora 35,默认的php是8.0版本,有一个原来的index.php不能再用了,还有mediawiki的老版本(1.32)不能用了
  • /etc/php.ini
  • 其中默认的上传文件是2M
  • 简单的php
<htm>
 <body>
   It works!
 <?php
  phpinfo();
 ?>
</body>
</html>
  • 调用外部命令,exec 或者system
 system("date",$arr);
 exec("ls",$out,$status);
 print_r($out);
 print_r($status);
  • 注意命令的权限
  • 从url获取关键词,比如php?mjd=12345&pid=assass&sid=12&fid=21
 $mjd=$_GET["mjd"];
 $pid=$_GET["pid"];
 $sid=$_GET["sid"];
 $fid=$_GET["fid"];
 $name ="spec/spec-".$mjd."-".$pid."_sp".$sid."-".$fid.".fits";注意字符串合并用'.'
  • 从表单通过post获取关键词
html 文件
<html>
  <body>
 <form action="welcome.php" method="post"> 
  your name: <input type="text" name="name" />
  <input type="submit" />
 </form>
</body>
</html>
php文件
<html>
 <body>
 <?php
  $name=$_POST["name"];
  echo "your: $name"; 
 ?>
</body>
</html>