@1kbfree
2018-06-11T22:20:24.000000Z
字数 1038
阅读 1059
PHP
<meta charset="utf-8"> //已utf-8的格式输出,否则有中文输出到网站上会乱码。
<?php
/**
* @Author: iamfree
* @Date: 2018-03-31 17:33:58
* @Last Modified by: iamfree
* @Last Modified time: 2018-03-31 22:15:51
*/
class Cls{
/*类中的变量叫做类属性,类中的函数叫做类方法*/
public $name = 'iamfree'; //类属性
public $time = 2018; //类属性
public function Func(){
echo "this is a".__FUNCTION__."函数";
}
}
$c = new Cls(); //实例化类对象
var_dump($c); //打印类的详细信息
echo "<br>";
$c -> Func(); //执行类中的方法
echo "<br>";
echo $c -> time;
echo "<br>";
echo $c -> name;
echo "<br>";
//$this用法
class Cls2{
public $num;
function setNum($num){
$this -> num = $num;
echo $this -> num;
echo "<br>";
}
}
$c2 = new Cls2;
echo $c2 -> setNum(520);
echo $c2 -> setNum(1314);
object(Cls)#1 (2) {
["name"]=>
string(7) "iamfree"
["time"]=>
int(2018)
}
<br>this is aFunc函数<br>2018<br>iamfree<br>520<br>1314<br>
if(isset($_POST['submit'])){
if($_FILES['file']['type']=='image/png' or $_FILES['file']['type']=='image/jpeg' or $_FILES['file']['type']=='image/php'){ //这里对上传的文件的MIME类型进行了判断
$name = '上传成功!上传的文件是:'.$_FILES['file']['name'].' ';
$size = '文件大小是:'.$_FILES['file']['size'].' ';
}else{
$name = '抱歉!你上传的文件有误,请阻止你那肮脏的思想~';
}
}else{
$name = "你没上传文件";
}