search

3.12php

Jun 13, 2016 am 09:41 AM
aspnetsoftware programming

这是我的第一个博客  纪念一下  反正都是自己看

第一个问题 出现错误

当图片超过1M时就可能出现以下错误  当然这个也跟你php.ini设置有关 如果你php设置里 memory_limit 16M 这个过小的话就会出现下面这个错误!
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 3456 bytes) in
 
解决方法
ini_set("memory_limit", "60M");
在 imagecreatefromjpeg 前动态设置大小 以解决内存不足问题
有的服务器可能限制了这个函数的使用 ini_set()     这样的话就会既不报错 也无法生成缩略图 
所以只有联系服务器那边手动把php.ini修改一下

 

 

第二个问题  获取文件名

basename
basename -- 返回路径中的文件名部分
$path = "/home/httpd/html/index.php";
$file = basename($path);        // $file is set to "index.php"
$file = basename($path,".php"); // $file is set to "index"
?>

 

第三个问题  边执行 边输出
print "一共5个档案要处理


";
sleep(1);
print str_pad("",100000);
flush();
for($i=1;$i{
sleep(1);
print  "#$i 完毕
";
print str_pad("",10000);
flush();
}
print "恭喜,全部处理成功!";

 

第四个问题 mysql_pconnect()

mysql_pconnect() 函数打开一个到 MySQL 服务器的持久连接。
mysql_pconnect() 和 mysql_connect() 非常相似,但有两个主要区别:
当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。
其次,当脚本执行完毕后到 SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(mysql_close() 不会关闭由 mysql_pconnect() 建立的连接)

但使用Pconnect会经常的导致Mysql连接失败,提示连接太多,原因在于pconnect后,Apache不会自动关闭mysql的连接.

我的理解:至于我一直不明白的mysql_pconnect何时关闭,我想只有数据库关闭的时候才关闭吧。。。。
mysql_connect()根本不是在程序执行完毕就关闭的,因为加入我第一个次执行程序用mysql_connect连接,第二次将连接去 掉,还是能够查询。说明mysql_connect()根本不是在程序执行完毕就关掉,而是有一个保持时间,这就是所谓的,mysql连接时长。
至于mysql_pconnect是一直持续保持连接,没有时长限制,直到数据库关闭连接。mysql_pconnect每次连接时候,会先查找是否有可用连接,原话:当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。
那么mysql_connect是否也会在连接时候先查找可用连接呢?通过查找php手册,找到相关。原话:如果用同样的参数第二次调用 mysql_connect(),将不会建立新连接,而将返回已经打开的连接标识。

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

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

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment