search
HomeBackend DevelopmentPHP Tutorial 【转】PHP根本知识点

【转】PHP基本知识点

原文地址:http://blog.csdn.net/hyslx27/article/details/6180028

?

?

1. HTTP协议中几个状态码的含义:503 500 401 200 301 302。
??? HTTP状态码

??? 1**:请求收到,继续处理
??? 2**:操作成功收到,分析、接受
??? 3**:完成此请求必须进一步处理
??? 4**:请求包含一个错误语法或不能完成
??? 5**:服务器执行一个完全有效请求失败

??? 500――服务器产生内部错误
??? 501――服务器不支持请求的函数
??? 502――服务器暂时不可用,有时是为了防止发生系统过载
??? 503――服务器过载或暂停维修

??? 400――错误请求,如语法错误
??? 401――请求授权失败
??? 403――请求不允许

??? 200――交易成功
??? 201――提示知道新文件的URL
??? 202――接受和处理、但处理未完成
??? 203――返回信息不确定或不完整
??? 204――请求收到,但返回信息为空
??? 205――服务器完成了请求,用户代理必须复位当前已经浏览过的文件
??? 206――服务器已经完成了部分用户的GET请求

??? 300――请求的资源可在多处得到
??? 301――删除请求数据
??? 302――在其他地址发现了请求数据


?? 2. Include require include_once require_once 的区别.

??? include() 、require()语句包含并运行指定文件。这两结构在包含文件上完全一样,唯一的区别是对于错误的处理。require()语句在遇到包含文件不存在,或是出错的时候,就停止即行,并报错。include()则继续即行。
??? include_once()和require_once()一样,应该用于在脚本执行期间同一个文件有可能被包含超过一次的情况下,想确保它只被包含一 次以避免函数重定义,变量重新赋值等问题。这就是include_once()和require_once()与include() 和require()的主要区别。

?? 3. PHP/Mysql中几个版本的进化史,比如mysql4.0到4.1,PHP 4.x到5.1的重大改进等 等。

? ? 4. HEREDOC介绍

??? heredoc 是可以让我们在php代码内实现一大段的html代码,并且可以在其中,使用php变量。
??? 1.以 ??? 2.位于开始标记和结束标记之间的变量可以被正常解析,但是函数则不可以。
??? 3.heredoc常用在输出包含大量HTML语法d文档的时候。比如:函数outputhtml()要输出HTML的主页。可以有两种写法。很明显第二种写法比较简单和易于阅读。


?? 5. 写出一些php魔幻方法;


__construct 初始化 构造函数
__destruct 卸载 析构函数
__autoload 自动加载函数
__call?? 调用不存在的类的函数的时候得处理方法,__call 失败,就调用父类方法,依此类推
__get?? 获取属性值
__set()?? 设置属性值
__isset() 测定变量是否设定用的函数,传入一个变量作为参数,如果传入的变量存在则传回true,否则传回false
__unset() 删除指定的变量且传回true,参数为要删除的变量。
__clone();?? 克隆对象
__toString(); 进行对象的类型转换
__sleep();???
__wakeup();
当一个对象被串行化,PHP会调用__sleep方法(如果存在的话). 在反串行化一个对象后,PHP 会调用__wakeup方法. 这两个方法都不接受参数. __sleep方法必须返回一个数组,包含需要串行化的属性.

?? 6. 一些编译php时的configure 参数

?? 7. 向php传入参数的两种方法。


??? 在调用函数时,需要向函数传递参数,被传入的参数称为实参,而函数定义的参数为形参。参数传递的方式有两种。
??? 1.传值方式:将实参的值复制到对应的形参中,在函数内部的操作针对形参进行,操作的结果不会影响到实参,即函数返回后,实参的值不会改变。
??? 2.传址方式:实参的内存地址传递到形参中,在函数内部的所有操作都会影响到实参的值,即返回后,实参的值会相应发生变化。传址时只需要在形参前加&号即可。


?? 8. (mysql)请写出数据类型(int char varchar datetime text)的意思; 请问varchar和char有什么区别;


??? Varchar保存的值是可变长度,CHAR是固定长度,如果保存的值不足你定义的长度,SQL会在后面追加空格,直到你定义的字段长度.


?? 9. error_reporting 等调试函数使用


??? error_reporting()函数是用来重新定义页面显示错误等级的函数,这个函数可以覆盖掉PHP.ini针对程序运行时错误报告等级的配置。
error_reporting()函数能够使用的参数列表和这些参数的数字值:

值 常量
1 E_ERROR

2 E_WARNING

4 E_PARSE

8 E_NOTICE

16 E_CORE_ERROR

32 E_CORE_WARNING

64 E_COMPILE_ERROR

128 E_COMPILE_WARNING

256 E_USER_ERROR

512 E_USER_WARNING

1024 E_USER_NOTICE

2047 E_ALL

2048 E_STRICT

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools