PHP面试题目
最近的事情比较杂乱无章,没有安心下来工作,闲下来无事总结一些PHP的面试题目吧。
1.表单中get与post的提交方式的区别
get用户端将数据加到url后面,如submit.php?id=123&name=yanggong,从而get存在一定的安全问题。
get传输的数据量小,主要是因为url长度的限制,而post可以传输大量的数据。
get限制表单中数据集的范围asc2码,而post可以支持整个iso10646字符集。
2.session与cookie的区别
cookie是保存在客户端的信息,是一种远程浏览器储存数据并以此来跟踪和识别用户的机制。PHP的http协议的头信息里发送cookie,因此setcookie()函数必须在其他信息出去前调用,和header()函数的限制类似。
session是保存在服务器端的信息,从这个角度,session比cookie更安全。当会话创建时,服务器返回客户端一个加密的session_id以识别用户身份,浏览器关闭,session销毁,从而session存的值就没有了。
3.echo print??print_r printf 的区别
echo是php语句,没有返回值,输出一个或多个
print()和print_r()是函数,有返回值。print打印简单类型变量,而print_r()可以打印数组对像复杂变量。
printf() 函数输出格式化的字符串。
4.mysql_fetch_array()与mysql_fetch_row()区别
mysql_fetch_array()返回根据从结果集取得的行生成数组,如果没有更多行,返回false.??可以以字段名和数字做索引。
mysql_fetch_row()返回结果集中取得一行作为枚举数组,返回一个数字的数据,偏移量为0,只能数字做索引
5.PHP面向对象的基本知识????_set() _get() __construct()??public private protected
_set()??用于为属性设置值
_get()??获取属性的值
__construct??在一个类中只能声明一个构造方法,每次创建对象的时候回去调用一次构造方法,不能主动地调用这个方法,所以通常用它执行一些有用的初始化任务。
public表示全局,类内部外部子类都可以访问
private表示私有,只有本类内部可以调用
protected表示受保护的,只有本类或子类或父类可以访问。
6.谈谈事务?
事务就是一系列的操作,这些操作完成一个任务,只要其中有一个操作没有成功,事务就操作失败,发生回滚事件,即撤消前面的操作,这样可以保证数据的一致性。而且可以把操作暂时放在缓存里,等所有操作都成功有提交数据库,这样保证费时的操作都是有效操作。

The article discusses PHP, detailing its full form, main uses in web development, comparison with Python and Java, and its ease of learning for beginners.

PHP handles form data using $\_POST and $\_GET superglobals, with security ensured through validation, sanitization, and secure database interactions.

The article compares PHP and ASP.NET, focusing on their suitability for large-scale web applications, performance differences, and security features. Both are viable for large projects, but PHP is open-source and platform-independent, while ASP.NET,

PHP's case sensitivity varies: functions are insensitive, while variables and classes are sensitive. Best practices include consistent naming and using case-insensitive functions for comparisons.

The article discusses various methods for page redirection in PHP, focusing on the header() function and addressing common issues like "headers already sent" errors.

Article discusses type hinting in PHP, a feature for specifying expected data types in functions. Main issue is improving code quality and readability through type enforcement.

The article discusses PHP Data Objects (PDO), an extension for database access in PHP. It highlights PDO's role in enhancing security through prepared statements and its benefits over MySQLi, including database abstraction and better error handling.

Article discusses creating and securing PHP APIs, detailing steps from endpoint definition to performance optimization using frameworks like Laravel and best security practices.


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

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

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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.

SublimeText3 English version
Recommended: Win version, supports code prompts!
