search
HomeBackend DevelopmentPHP Tutorial和大家分享一下小弟我学php的前两个小时成绩(适合菜鸟)(散分)

和大家分享一下我学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, 时是无法打开文件的
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

mPDF

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),

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

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.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use