在用Apache2.4与php5.5配置独立环境的时候,打印phpinfo也显示成功,能看到开启的扩展项,但是就是不显示mysql的,也打开了mysql的扩展就是不显示,却显示了mysqlnd,测试连接mysql数据库也连接不上。不知道是什么原因
回复内容:
在用Apache2.4与php5.5配置独立环境的时候,打印phpinfo也显示成功,能看到开启的扩展项,但是就是不显示mysql的,也打开了mysql的扩展就是不显示,却显示了mysqlnd,测试连接mysql数据库也连接不上。不知道是什么原因
PHP从5.4开始默认采用mysqlnd实现mysql,mysqli,pdo_mysql.
编译时,PHP5.3这样启用mysqlnd支持:
<code>--with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd </code>
PHP5.4后留空则默认启用mysqlnd:
<code>--with-mysql --with-mysqli --with-pdo-mysql </code>
PHP7开始不再支持--with-mysql.
另外,如果你编译时没有添加 --with-mysql 配置项,自然也是不能使用mysql这个扩展的函数的.不过,PHP7开始将废弃mysql扩展,用户应该使用mysqli和pdo_mysql扩展.
PHP5.4.x开始默认使用mysqlnd连接mysql,区别于以前的libmysql,PHP内建支持mysqlnd,而且采用PHP license授权,避免了任何可能存在的版权问题.
http://www.php.net/manual/zh/mysql.installation.php
mysqlnd并不像libmysql那样作为通用库,它是专门为PHP而写的一个库.libmysql是直接访问数据库的,而mysqlnd是通过Zend访问数据库,有着更好的性能,可以在phpinfo()中查看到mysqlnd信息.以前编译PHP时,必须先安装MySQL,然后用--with-mysql=DIR指定MySQL的位置,有了内置的mysqlnd本地驱动,就不需要这样了.
除了解决版权问题外,mysqlnd比libmysql更快,更节省内存,而且提供了丰富的性能统计功能,也更方便PHP的编译.mysqlnd作为一个PHP扩展,跟PHP是紧耦合的,使用的是PHP的内存管理系统,所以内存占用要比libmysql少,效率也更高.可以用memory_get_usage()跟踪mysqlnd的内存使用,同时也受memory_limit的内存限制.
http://php.net/manual/en/mysqlnd.overview.php
PHP 从 5.5 开始废弃了原始的 MySQL 扩展,需使用 MySQLi 或 PDO_MySQL 扩展作为替代。

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

TomakePHPapplicationsfaster,followthesesteps:1)UseOpcodeCachinglikeOPcachetostoreprecompiledscriptbytecode.2)MinimizeDatabaseQueriesbyusingquerycachingandefficientindexing.3)LeveragePHP7 Featuresforbettercodeefficiency.4)ImplementCachingStrategiessuc

ToimprovePHPapplicationspeed,followthesesteps:1)EnableopcodecachingwithAPCutoreducescriptexecutiontime.2)ImplementdatabasequerycachingusingPDOtominimizedatabasehits.3)UseHTTP/2tomultiplexrequestsandreduceconnectionoverhead.4)Limitsessionusagebyclosin

Dependency injection (DI) significantly improves the testability of PHP code by explicitly transitive dependencies. 1) DI decoupling classes and specific implementations make testing and maintenance more flexible. 2) Among the three types, the constructor injects explicit expression dependencies to keep the state consistent. 3) Use DI containers to manage complex dependencies to improve code quality and development efficiency.

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


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

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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

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 Mac version
Visual web development tools
