linux,php5.4, 织梦dedecms后台登录空白,原因:
include/userlogin.class.php,里面有一个keepuser()函数,是用session_register来注册一个session变量,但是在php5.4中已经移除了这个功能
代码如下 | 复制代码 |
把@session_register($this->keepUserIDTag); 注释掉,然后改为 如下: |
我的修改前与修改后的代码
解决方法:找开include/userlogin.class.php文件,查找以下内容:
代码如下 | 复制代码 |
@session_register($this->keepUserIDTag); 替换成 global $admincachefile,$adminstyle; |
近期在给wordpress开发模板功能时发现,直接使用include(“文件名”)的形式调用其他php代码片段时会出现路径错误。之前服务器环境一直都是iis,未曾出现过类似的BUG,但换成linux服务器后便出现了路径调用错误。在网上搜寻了一番,发现可以在调用时使用dirname(__FILE__)来解决linux服务器下包含文件时的路径错误。
其实主要问题来自于linxu服务器下的站点根目录问题,在linux服务器下包含某个文件时,其路径为/home/web/。如果直接使用include(“/文件名”)的格式,则实际上包含的文件路径为/home/web/文件名。
完整的使用方法为include dirname(__FILE__) . ‘/page.php’
这段代码引用的文件需要与代码所在文件处于同一目录,如果需要调用上一层目录可以使用dirname(dirname(__FILE__))来调用上一层目录的文件。
如果大家在网站更换服务器后遇到包含类问题时,不妨检查一下网站是否有引用路径的错误。建议在书写php包含时就使用dirname(__FILE__)的方法引用文件,以解决多数情况下的引用问题。
今天在利用empty()函数判断一个变量是否为null是发现提示Note: empty() only checks variables as anything else will result in a parse error. In other words, the following will not work:empty(trim($name)).错误了,后整一半天找到问题所在了。
你使用empty检查一个函数返回的结果时会报如下的一个致命错误:
Fatal error: Can't use function return value in write context in : ..................
例如:
echo empty(yourfunction(xx, oo));
到PHP手册里面查看,在empty函数描述的地方有以下文字:
Note: empty() only checks variables as anything else will result in a parse error. In other words, the following will not work:empty(trim($name)).
empty() 只检测变量,检测任何非变量的东西都将导致解析错误!
因此,我们不能拿empty来直接检测函数返回的值,需要先把函数的返回值赋给某个变量,然后去用empty检测这个变量。
所以,我们可以写成如下的形式:
$return= yourfunction(xx, oo);
echo empty(return);
在php中imagecreate函数是一个图形处理函数,主要用于新建一个基于调色板的图像了,然后在这个基础上我们可以创建一些图形数字字符之类的,但这个函数需要GD库支持,如果没有开启GD库使用时会提示Call to undefined function imagecreate()错误。例,我在测试一个简单生成图形时实例
Example #1 新建一个新的 GD 图像流并输出图像
代码如下 | 复制代码 |
<?php |
运行机制时提示
Fatal error: Call to undefined function imagecreate() .....
后面突然想起没打开gd库了
这一问题是:GD库没有正确安装或配置,解决方案:
在php.ini中找到
;extension=php_gd2.dll
去掉前边的;
然后将php目录中的ext下的php_gd2.dll拷入c:/windows/system32和c:/windows目录下,重启IIS或者apache就OK了.
centos中gd库开启
具体操作只有2个命令如下:
运行在线安装带GD库的PHP的命令:
代码如下 | 复制代码 |
yum -y install php-gd |
重新启动apachce服务以使安装后的GD库生效
代码如下 | 复制代码 |
/etc/rc.d/init.d/httpd restart(service httpd restart) |
gd的安装路径
/etc/php.d/gd.ini <---这个是让php支持gd的哦,这个是CentOS的特色之一,不用把全部东西都写在php.ini这个文件里,只是需要把*.ini文件写在/etc/php.d/文件夹就可以了,系统会自动把这个目录下的*.ini读入php.ini
/usr/lib/php/modules/gd.so <----这个就是gd的文件啦
关于需要使用GD库的图形处理函数还有如下
gd_info
getimagesize
getimagesizefromstring
image_type_to_extension
image_type_to_mime_type
image2wbmp
imageaffine
imageaffinematrixconcat
imageaffinematrixget
imagealphablending
imageantialias
imagearc
imagechar
imagecharup
imagecolorallocate
imagecolorallocatealpha
imagecolorat
imagecolorclosest
imagecolorclosestalpha
imagecolorclosesthwb
imagecolordeallocate
imagecolorexact
imagecolorexactalpha
imagecolormatch
imagecolorresolve
imagecolorresolvealpha
imagecolorset
imagecolorsforindex
imagecolorstotal
imagecolortransparent
imageconvolution
imagecopy
imagecopymerge
imagecopymergegray
imagecopyresampled
imagecopyresized
» imagecreate
imagecreatefromgd2
imagecreatefromgd2part
imagecreatefromgd
imagecreatefromgif
imagecreatefromjpeg
imagecreatefrompng
imagecreatefromstring
imagecreatefromwbmp
imagecreatefromwebp
imagecreatefromxbm
imagecreatefromxpm
imagecreatetruecolor
imagecrop
imagecropauto
imagedashedline
imagedestroy
imageellipse
imagefill
imagefilledarc
imagefilledellipse
imagefilledpolygon
imagefilledrectangle
imagefilltoborder
imagefilter
imageflip
imagefontheight
imagefontwidth
imageftbbox
imagefttext
imagegammacorrect
imagegd2
imagegd
imagegif
imagegrabscreen
imagegrabwindow
imageinterlace
imageistruecolor
imagejpeg
imagelayereffect
imageline
imageloadfont
imagepalettecopy
imagepalettetotruecolor
imagepng
imagepolygon
imagepsbbox
imagepsencodefont
imagepsextendfont
imagepsfreefont
imagepsloadfont
imagepsslantfont
imagepstext
imagerectangle
imagerotate
imagesavealpha
imagescale
imagesetbrush
imagesetinterpolation
imagesetpixel
imagesetstyle
imagesetthickness
imagesettile
imagestring
imagestringup
imagesx
imagesy
imagetruecolortopalette
imagettfbbox
imagettftext
imagetypes
imagewbmp
imagewebp
imagexbm
iptcembed
iptcparse
jpeg2wbmp
png2wbmp
我先是把php.ini中的extension=php_curl.dll前面的;去掉了,并且重启了apache环境,但调用如下函数时提示
代码如下 | 复制代码 |
<?php |
错误提示
Call to undefined function curl_init()
看了相关文章我又把将PHP的ext目录下的三个文件:php_curl.dll、libeay32.dll和ssleay32.dll复制到系统system32目录中,但还是不行,于是再接google发现win7(x64)有一点区别了自带的php_curl.dll文件在64位windows7环境下并不能运作
具体解决步骤:
1、单击通知栏wamp图标,在php-ext里找到php_curl选项,单击选中,等待wamp重启服务完成。
2、下载修复过的php_curl.dll(php5.X/X64位系统)文件,放置到wampbinphpphp(版本号)ext文件夹下。
3、重新启动wamp服务即可。
提示
找了这么久原来是我们安装的php环境与系统版本不同,我们最好是多少位系统选择多少位的php版本哦。