随笔分类 - php
摘要:引进数据 mysql> create database stu1 character set utf8; mysql> use stu1 mysql> set names utf8; mysql> source c:/stu1.sql; 连接数据库 <?php $db=new mysqli("loc
阅读全文
摘要:抽象类 不能被实例化,用于其他类的继承。使用abstract(抽象)。抽象方法一定是抽象类,抽象类不一定有抽象方法。 接口interface是特殊的抽象类。 eg: <?php //抽象类 abstract class person{ function run(){ echo "runing…………
阅读全文
摘要:<?phpclass person{ public $name; private $age; public $sex; const WOMAN=0; const MAN=1; function __construct($name,$age){ $this->name=$name; $this->ag
阅读全文
摘要:首先是登入页面 <form action="" method="post"> <input type="text" name="uname"><br /> <input type="password" name="psw"><br /> <input type="submit" name="btn"
阅读全文
摘要:<?phpob_clean();$img=imagecreate(40,20);$back=imagecolorallocate($img,200,200,200); $blue=imagecolorallocate($img,100,0,200); // $num=rand(1000,9999);
阅读全文
摘要:<?phpob_clean();$img=imagecreate(400,400);$back=imagecolorallocate($img,200,200,100); $blue=imagecolorallocate($img,100,0,200);$red=imagecolorallocate
阅读全文
摘要:<meta charset="utf-8"><?php// $fn=fopen("c:\\abc.txt","w"); // fwrite($fn,"hello world"); // fclose($fn); // $fn=fopen("c:\\news.txt","r"); // while(!
阅读全文
摘要:<?php $arr=array(20,30,50,40); array_push($arr,33);//push新值到数组结尾 print_r($arr); array_unshift($arr,11);//数组前添加数据 print_r($arr); $a=array_pop($arr);//数
阅读全文
摘要:20191108数组组合练习案例 <div>输入姓名和成绩:</div> <form action='' method='post'> <?php for($i=0;$i<5;$i++){ ?> <div> <input type='text' name='uname[]' placeholder=
阅读全文
摘要:<?php $arr=[20,30,60]; $new=array(22,"tom"=>33); echo $arr[2]; echo $new['tom']; foreach($new as $v){ echo $v; } $str="how are you"; $strarr=explode("
阅读全文
摘要:数组排序 <style>*{font-size:25px;}</style> <?php // sort 去除键名升序 // asort 保留键名升序 assoc // $arr=array("peter"=>15,"tony"=>6,"tom"=>12); // asort($arr); // p
阅读全文
摘要:数组练习 <?php //创建的方式 //1 $arr=array(20,30,50); //2 $arr1=[30,60,70]; //3 //当遇到这种情况的时候键(key)是相同的,会取后面的赋值(value) //TRUE为1,数字不为1.1或者为2.1的键都为整数部分的键. $arr2=[
阅读全文
摘要:<?php $today=time(); //获取传过来的‘年’ 不然获取当年的‘年’ $year=isset($_GET['year'])?$_GET['year']:date("Y",$today); //获取传过来的‘月’ 不然获取当年的‘月’ $month=isset($_GET['mont
阅读全文
摘要:<?phpecho abs(-23);echo "<hr/>";echo date("t");echo "<hr/>";echo mt_rand();echo "<hr/>";echo floor(pi());echo "<hr/>";echo ceil(pi());echo "<hr/>"; $s
阅读全文
摘要:<?php$str="what is you name?";$arr=array('i','s');$arr_1=array('s','i');//是先后替换的。echo str_replace($arr,$arr_1,$str);//(筛选替换数,替换数,本来的string)echo "<br/>
阅读全文
摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <form action="index.php" method="post"> 你上的课程是?<br /> <input type="checkbox" name='course[]' value='语
阅读全文
摘要:<?php$arr=["tom","peter","mary"];$str=implode("+",$arr);//implode array(数组)元素中间加上【“+”】的str。echo $str;$s="How Old Are You!!";$s1="abc..de.16.3.doc";$ne
阅读全文
摘要:<style>*{font-size: 30px;}</style> //传地址 &<?phpfunction sum($a,&$b){ $c=$a+$b; $b++; return $c;}$m=3;echo sum(1,$m)+6; //10echo "<br />".$m; //4 ?> //
阅读全文
浙公网安备 33010602011771号