基于PHP选项与信息函数的使用详解_PHP教程
bool assert ( mixed $assertion [, string $description ] ) — 检查一个断言是否为 FALSE
assert_options(ASSERT_ACTIVE, true);//允许使用assert()函数
assert_options(ASSERT_WARNING, false);//在assert失败时不输出警告信息
assert_options(ASSERT_BAIL, true);//assert失败后终止代码执行
assert_options(ASSERT_CALLBACK, 'getMsg');//assert失败后终止代码执行。
echo '开始:
';
assert('mysql_query("")');
echo '测试成功!';
function getMsg(){
echo '出错啦!';
}
mixed assert_options ( int $what [, mixed $value ] ) — 设置 assert() 的各种控制选项,或者查询当前的设置
ASSERT_ACTIVE : 是否启用 assert() 断言, ini配置 assert.active,默认值 1
ASSERT_WARNING :是否为每个失败的断言产生一个 PHP 警告,ini配置 assert.warning,默认1
ASSERT_BAIL :是否在断言失败时中止执行,ini配置 assert.bail,默认值0
ASSERT_QUIET_EVAL :是否在断言表达式求值时禁用 error_reporting,ini配置assert.quiet_eval,默认值0
ASSERT_CALLBACK :断言失败时调用回调函数,ini配置assert.callback
assert_options(ASSERT_ACTIVE, true);//允许使用assert()函数
assert_options(ASSERT_WARNING, false);//在assert失败时不输出警告信息
assert_options(ASSERT_BAIL, true);//assert失败后终止代码执行
assert_options(ASSERT_CALLBACK, 'getMsg');//assert失败后终止代码执行。
echo '开始:
';
assert(is_int(1.2));//检测结果为fales
echo '测试成功!';
function getMsg(){
echo '出错啦!';
}
bool dl( string $library ) — 获取 PHP 配置选项的值 载入指定的 PHP扩展
if(!extension_loaded('sqlite')){//测试指定的扩展是否已经激活
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
int gc_collect_cycles() — 强制收集所有现存的垃圾循环周期
void gc_disable ( void ) — 停用循环引用收集器
void gc_enable ( void ) — 激活循环引用收集器
bool gc_enabled ( void ) — 返回循环引用计数器的状态
string get_cfg_var ( string $option ) — 获取 PHP 配置选项的值获取 PHP 配置选项的值
string get_current_user ( void )— 获取当前 PHP 脚本所有者名称
array get_defined_constants ([ bool $categorize = false ] )— 返回所有常量的关联数组
array get_extension_funcs ( string $module_name )— 返回模块函数名称的数组
print_r(get_extension_funcs("xml"));
string get_include_path ( void ) — 获取当前的 include_path 配置选项
array get_included_files ( void )— 返回被 include 和 require 文件名的 array
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';
$included_files = get_included_files();
foreach ($included_files as $filename){
echo "$filename\n";
}
array get_loaded_extensions ([ bool $zend_extensions = false ] )— 返回所有编译并加载模块名的 array
bool get_magic_quotes_gpc ( void )— 获取当前 magic_quotes_gpc 的配置选项设置
bool get_magic_quotes_runtime ( void ) — 获取当前 magic_quotes_runtime 配置选项的激活状态
string getenv ( string $varname ) — 获取一个环境变量的值
$ip = getenv('REMOTE_ADDR');
int getlastmod ( void )— 获取页面最后修改的时间
int getmygid ( void )— 获取当前 PHP 脚本拥有者的 GID
int getmyinode ( void )— 获取当前脚本的索引节点(inode)
int getmypid ( void )— 获取 PHP 进程的 ID
int getmyuid ( void )— 获取 PHP 脚本所有者的 UID
array getopt ( string $options [, array $longopts ] )— 从命令行参数列表中获取选项
array getrusage ([ int $who = 0 ] ) — 获取当前资源使用状况
array ini_get_all ([ string $extension [, bool $details = true ]] ) — 获取所有配置选项
print_r(ini_get_all("pcre"));
print_r(ini_get_all());
string ini_get ( string $varname ) — 获取一个配置选项的值
void ini_restore ( string $varname )— 恢复配置选项的默认值
string ini_set ( string $varname , string $newvalue )— 为一个配置选项设置值
main — 虚拟的 main()int memory_get_peak_usage ([ bool $real_usage = false ] )— 返回分配给 PHP 内存的峰值int memory_get_usage ([ bool $real_usage = false ] ) — 返回分配给 PHP 的内存量
string php_ini_loaded_file ( void ) — 取得已加载的 php.ini 文件的路径
string php_ini_scanned_files ( void )— 返回从额外 ini 目录里解析的 .ini 文件列表
string php_sapi_name ( void ) — 返回 web 服务器和 PHP 之间的接口类型
string php_uname ([ string $mode = "a" ] )— 返回运行 PHP 的系统的有关信息
'a':此为默认all。
's':操作系统名称
'n':主机名。例如: localhost.example.com。
'r':版本名称,例如: 5.1.2-RELEASE。
'v':版本信息。操作系统之间有很大的不同。
'm':机器类型。例如:i386。
bool phpcredits ([ int $flag = CREDITS_ALL ] ) — 打印 PHP 贡献者名单
CREDITS_ALL :所有的
CREDITS_DOCS : 文档组贡献名单
CREDITS_FULLPAGE : 常用于和其他标志进行组合。 表示需要打印包含其他标志表示信息的独立 HTML 页面。
CREDITS_GENERAL : 普遍名单:语言设计与理念、PHP作者以及 SAPI 模块
CREDITS_GROUP : 核心开发者名单
CREDITS_MODULES : PHP 扩展模块以及作者
CREDITS_SAPI : PHP 的服务器 API 模块以及作者
phpcredits(CREDITS_GROUP | CREDITS_DOCS | CREDITS_FULLPAGE);
bool phpinfo ([ int $what = INFO_ALL ] ) — 输出关于 PHP 配置的信息
string phpversion ([ string $extension ] ) — 获取当前的PHP版本
bool putenv ( string $setting )— 设置环境变量的值
void restore_include_path ( void ) — 还原 include_path 配置选项的值
string set_include_path ( string $new_include_path ) — 设置 include_path 配置选项
void set_time_limit ( int $seconds )— 设置脚本最大执行时间,从它本身开始计时,0表示不限时
string sys_get_temp_dir ( void ) — 返回用于临时文件的目录
mixed version_compare ( string $version1 , string $version2 [, string $operator ] ) — 对比两个PHP 规范化的版本数字字串
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
echo '我的PHP版本很高: ' . PHP_VERSION . "\n";
}
int zend_thread_id ( void ) — 返回当前线程的唯一识别符
string zend_version ( void ) — 获取当前 Zend 引擎的版本

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Sujets chauds



Dans ce chapitre, nous comprendrons les variables d'environnement, la configuration générale, la configuration de la base de données et la configuration de la messagerie dans CakePHP.

PHP 8.4 apporte plusieurs nouvelles fonctionnalités, améliorations de sécurité et de performances avec une bonne quantité de dépréciations et de suppressions de fonctionnalités. Ce guide explique comment installer PHP 8.4 ou mettre à niveau vers PHP 8.4 sur Ubuntu, Debian ou leurs dérivés. Bien qu'il soit possible de compiler PHP à partir des sources, son installation à partir d'un référentiel APT comme expliqué ci-dessous est souvent plus rapide et plus sécurisée car ces référentiels fourniront les dernières corrections de bogues et mises à jour de sécurité à l'avenir.

Pour travailler avec la date et l'heure dans cakephp4, nous allons utiliser la classe FrozenTime disponible.

Travailler avec la base de données dans CakePHP est très simple. Nous comprendrons les opérations CRUD (Créer, Lire, Mettre à jour, Supprimer) dans ce chapitre.

Pour travailler sur le téléchargement de fichiers, nous allons utiliser l'assistant de formulaire. Voici un exemple de téléchargement de fichiers.

Dans ce chapitre, nous allons apprendre les sujets suivants liés au routage ?

CakePHP est un framework open source pour PHP. Il vise à faciliter grandement le développement, le déploiement et la maintenance d'applications. CakePHP est basé sur une architecture de type MVC à la fois puissante et facile à appréhender. Modèles, vues et contrôleurs gu

Le validateur peut être créé en ajoutant les deux lignes suivantes dans le contrôleur.
