和大家分享一下我学php的前两个小时成绩(适合初学者)(散分)
学习自:
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->http://www.w3school.com.cn/php/
1.php 文件必须是:
语句在这里写
?>
2.echo 输出函数 方法:echo “abc”
3.定义变量:$变量名 = 变量值
4.两个变量联合输出用“.”连接 例如:echo $变量1.变量2
5.strlen()函数是表示 变量值的长度
例如echo strlen(“Hello world!”);输出12
6.strpos()函数表示检索字符串 查找字符串在某个字符串中的位置
7.运算符
算数运算符
运算符 说明 例子 结果
+ Addition x=2
x+2 4
- Subtraction x=2
5-x 3
* Multiplication x=4
x*5 20
/ Division 15/5
5/2 3
2.5
% Modulus (division remainder) 5%2
10%8
10%2 1
2
0
++ Increment x=5
x++ x=6
-- Decrement x=5
x-- x=4
赋值运算符
运算符 说明 例子
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y
比较运算符
运算符 说明 例子
== is equal to 5==8 returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
>= is greater than or equal to 5>=8 returns false
逻辑运算符
运算符 说明 例子
&& and x=6
y=3
(x 1) returns true
|| or x=6
y=3
(x==5 || y==5) returns false
! not x=6
y=3
!(x==y) returns true
8.函数date("D");时间函数 返回当天信息
9.定义集合:$name = array(“刘文成”,”程海燕”,”myPHP”);
10.for循环
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$i=0; for($i=1;i”;}
11.foreach 循环
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$arr = array(“one”,”two”,”three”); foreach($arr as $value){ echo “我变了集合项目”.$value}
12.函数定义关键字:function
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php function w(){ echo “liuwencheng”;}echo “我的名字是:”;w();?>
13.function w($name1,$name2)--=>放参数
14.在函数中return用于返回值
15.$_POST[“name”]或者$_GET[“name”]是获得表单提交的值
16. $_COOKIE[“name”]获得cookie的值
17.$_REQUEST[“name”]包含了$_POST $_GET $_COOKIE
18.data(format,timesamp);
函数含义:时间
参数含义:format:必须,规定时间的格式
Timesamp
例子:echo data(“y/m/d”) ;
echo data(“y.m.d”);
echo data(“y-m-d”);
以上输出:
2006/07/11
2006.07.11
2006-07-11
19. mktime(hour,minute,second,month,day,year,is_dst)
函数含义:时间点
Is_dst是可选参数 其他参数可选
20.include(“head.php”)函数
设置 head.php 文件为页眉文件
例如:
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?php include("header.php"); ?><h1 id="Welcome-to-my-home-page">Welcome to my home page</h1><p>Some text</p>
21.require(“head.php”)函数
与include()函数几乎一样 只是错误的处理方式不一样
include除了错还会执行后面的php代码 而require则立即返回
22.fopen();在php页面中打开文件
参数有两个:参数a为文件路径
参数b问文件打开模式
这里面对参数b进行解释:
“r” --=>只读,在文件的开头开始
“r+”--=>读写,在文件的卡头开始
“w”--=>只写,打开文件并清空文件内容,如果不存在文件则创建
“w+”--=>读/写,打开文件并清空文件内容,如果不存在文件则创建
“a”--=>追加,打开文件并向文件末端进行写操作,如果文件不存在则创建新文件
“a+”--=>读/追加,向文件末端写内容,并保持文件
“x”--=>只写 创建文件,如果文件存在则返回false
“x+”--=>读/写。创建文件 如果文件已存在,则返回false和一个错误
注释*:如果fopen()无法打开指定的文件则发挥0(false)
例子1:$file=fopen(“D:/abc.txt”,”r”);
例子2:$file=fopen(“D:/abc.txt”,”r”) or exit(“unable to open file!”);
注:此例子如果文件无法打开则弹出消息
23.feof($file)用来检索是否已经达到文件末端
注释:在权限为:w, a, x, 时是无法打开文件的

许多用户在选择智能手表的时候都会选择的华为的品牌,其中华为GT3pro和GT4都是非常热门的选择,不少用户都很好奇华为GT3pro和GT4有什么区别,下面就就给大家介绍一下二者。华为GT3pro和GT4有什么区别一、外观GT4:46mm和41mm,材质是玻璃表镜+不锈钢机身+高分纤维后壳。GT3pro:46.6mm和42.9mm,材质是蓝宝石玻璃表镜+钛金属机身/陶瓷机身+陶瓷后壳二、健康GT4:采用最新的华为Truseen5.5+算法,结果会更加的精准。GT3pro:多了ECG心电图和血管及安

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

为什么截图工具在Windows11上不起作用了解问题的根本原因有助于找到正确的解决方案。以下是截图工具可能无法正常工作的主要原因:对焦助手已打开:这可以防止截图工具打开。应用程序损坏:如果截图工具在启动时崩溃,则可能已损坏。过时的图形驱动程序:不兼容的驱动程序可能会干扰截图工具。来自其他应用程序的干扰:其他正在运行的应用程序可能与截图工具冲突。证书已过期:升级过程中的错误可能会导致此issu简单的解决方案这些适合大多数用户,不需要任何特殊的技术知识。1.更新窗口和Microsoft应用商店应用程

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
