这篇文章主要介绍了PHP的关于变量和日期处理的一些面试题目整理,也是PHP入门学习中的基础知识,需要的朋友可以参考下
变量相关
PHP变量的内部实现
编程语言的系统类型分为强类型和弱类型两种:
php变量类型及存储结构
php在声明或使用变量的时候,并不需要显式指明其数据类型
php是弱类型语言,这不并表示php没有类型,在php中,存在8种变量类型,可以分为三类:
变量存储结构
变量的值存储到一下所示的zval结构体中.其结构如下:
typedef struct _zval_struct zval; struct _zval_struct { zvalue_value value; // 存储变量的值 zend_uint refcount__gc; // 表示引用计数 zend_uchar type; // 变量具体的类型 zend_uchar is_ref_gc; // 表示是否为引用 };
变量的值存储在另外一个结构体zvalue_value中
变量类型
zval结构体的type字段就是实现弱类型最关键的字段了,type的值可以为:IS_NULL, IS_BOOL, IS_LONG, IS_DOUBLE, IS_STRING, IS_ARRAY, IS_OBJECT, IS_RESOURCE之一.从字面上就很好理解,他们只是类型的唯一标示,根据类型的不同将不同的值存储到value字段
变量值的存储
前面说到变量的值存储在zvalue_value结构体中,结构体定义如下:
typedef union _zvalue_value { long lval; double dval; struct { char *val; int len; } str; HashTable *ht; zend_object_value obj; } _zvalue_value;
日期相关
计算两个日期之间的天数
,

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

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.

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

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