脚本宝典收集整理的这篇文章主要介绍了使用PHP访问Static方法的最佳方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
PRivate $my_paths = array( 'ImageMagick' => 'E:\Server\_ImageOptimize\ImageMagick','pngcrush' => 'E:\Server\_ImageOptimize\pngCrush\pngcrush.exe','jPEgtran' => 'E:\Server\_ImageOptimize\jpegtran\jpegtran.exe','gifsicle' => 'E:\Server\_ImageOptimize\gifsicle\gifsicle.exe','pngquant' => 'E:\Server\_ImageOptimize\pngquant\pngquant.exe','pngout' => 'E:\Server\_ImageOptimize\pngout\pngout.exe' );
public static function is_image($file_path) { $imagemagick = $this->my_paths['imagemagick']. '\identify'; echo $imagemagick; }
当然这会给我错误
Fatal error: Using $this when not in object context...
然后我尝试访问这样的属性:: my_paths [‘imagemagick’],但没有帮助.
我该如何处理?
self::$my_paths['imagemagick']
而my_paths没有声明为静态.所以你需要它
private static $my_paths = array(...);
当它的前面没有“static”关键字时,它期望在一个对象中实例化.
以上是脚本宝典为你收集整理的使用PHP访问Static方法的最佳方法全部内容,希望文章能够帮你解决使用PHP访问Static方法的最佳方法所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。