已弃用:each() 函数已弃用。 C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php 在第 66 行 [重复]
Posted
技术标签:
【中文标题】已弃用:each() 函数已弃用。 C:\\xampp\\htdocs\\phprojekt\\library\\Zend\\Cache\\Backend.php 在第 66 行 [重复]【英文标题】:Deprecated: The each() function is deprecated. C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php on line 66 [duplicate]已弃用:each() 函数已弃用。 C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php 在第 66 行 [重复] 【发布时间】:2018-09-01 07:55:48 【问题描述】:我是一名大学生。
我必须安装 XAMPP,然后安装一个名为 phprojekt 的程序才能与 XAMPP 一起使用。
这是安装 PHProjekt 以便将其与 XAMPP 一起使用的过程的快速视频。
https://www.youtube.com/watch?v=bfnGns5WiAY
当我到达必须登录 PHProjekt 的部分时,我无法进入并收到一条消息:
“不推荐使用:不推荐使用 each() 函数。此消息将在 C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php 中的第 66 行进一步调用时被抑制”
enter image description here
Backend.php 文档中的代码如下:
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Backend.php 20882 2010-02-03 18:19:44Z matthew $
*/
/**
* @package Zend_Cache
* @subpackage Zend_Cache_Backend
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Cache_Backend
/**
* Frontend or Core directives
*
* =====> (int) lifetime :
* - Cache lifetime (in seconds)
* - If null, the cache is valid forever
*
* =====> (int) logging :
* - if set to true, a logging is activated throw Zend_Log
*
* @var array directives
*/
protected $_directives = array(
'lifetime' => 3600,
'logging' => false,
'logger' => null
);
/**
* Available options
*
* @var array available options
*/
protected $_options = array();
/**
* Constructor
*
* @param array $options Associative array of options
* @throws Zend_Cache_Exception
* @return void
*/
public function __construct(array $options = array())
while (list($name, $value) = each($options))
$this->setOption($name, $value);
/**
* Set the frontend directives
*
* @param array $directives Assoc of directives
* @throws Zend_Cache_Exception
* @return void
*/
public function setDirectives($directives)
if (!is_array($directives)) Zend_Cache::throwException('Directives parameter must be an array');
while (list($name, $value) = each($directives))
if (!is_string($name))
Zend_Cache::throwException("Incorrect option name : $name");
$name = strtolower($name);
if (array_key_exists($name, $this->_directives))
$this->_directives[$name] = $value;
$this->_loggerSanity();
/**
* Set an option
*
* @param string $name
* @param mixed $value
* @throws Zend_Cache_Exception
* @return void
*/
public function setOption($name, $value)
if (!is_string($name))
Zend_Cache::throwException("Incorrect option name : $name");
$name = strtolower($name);
if (array_key_exists($name, $this->_options))
$this->_options[$name] = $value;
/**
* Get the life time
*
* if $specificLifetime is not false, the given specific life time is used
* else, the global lifetime is used
*
* @param int $specificLifetime
* @return int Cache life time
*/
public function getLifetime($specificLifetime)
if ($specificLifetime === false)
return $this->_directives['lifetime'];
return $specificLifetime;
/**
* Return true if the automatic cleaning is available for the backend
*
* DEPRECATED : use getCapabilities() instead
*
* @deprecated
* @return boolean
*/
public function isAutomaticCleaningAvailable()
return true;
/**
* Determine system TMP directory and detect if we have read access
*
* inspired from Zend_File_Transfer_Adapter_Abstract
*
* @return string
* @throws Zend_Cache_Exception if unable to determine directory
*/
public function getTmpDir()
$tmpdir = array();
foreach (array($_ENV, $_SERVER) as $tab)
foreach (array('TMPDIR', 'TEMP', 'TMP', 'windir', 'SystemRoot') as $key)
if (isset($tab[$key]))
if (($key == 'windir') or ($key == 'SystemRoot'))
$dir = realpath($tab[$key] . '\\temp');
else
$dir = realpath($tab[$key]);
if ($this->_isGoodTmpDir($dir))
return $dir;
$upload = ini_get('upload_tmp_dir');
if ($upload)
$dir = realpath($upload);
if ($this->_isGoodTmpDir($dir))
return $dir;
if (function_exists('sys_get_temp_dir'))
$dir = sys_get_temp_dir();
if ($this->_isGoodTmpDir($dir))
return $dir;
// Attemp to detect by creating a temporary file
$tempFile = tempnam(md5(uniqid(rand(), TRUE)), '');
if ($tempFile)
$dir = realpath(dirname($tempFile));
unlink($tempFile);
if ($this->_isGoodTmpDir($dir))
return $dir;
if ($this->_isGoodTmpDir('/tmp'))
return '/tmp';
if ($this->_isGoodTmpDir('\\temp'))
return '\\temp';
Zend_Cache::throwException('Could not determine temp directory, please specify a cache_dir manually');
/**
* Verify if the given temporary directory is readable and writable
*
* @param $dir temporary directory
* @return boolean true if the directory is ok
*/
protected function _isGoodTmpDir($dir)
if (is_readable($dir))
if (is_writable($dir))
return true;
return false;
/**
* Make sure if we enable logging that the Zend_Log class
* is available.
* Create a default log object if none is set.
*
* @throws Zend_Cache_Exception
* @return void
*/
protected function _loggerSanity()
if (!isset($this->_directives['logging']) || !$this->_directives['logging'])
return;
if (isset($this->_directives['logger']))
if ($this->_directives['logger'] instanceof Zend_Log)
return;
Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
// Create a default logger to the standard output stream
require_once 'Zend/Log.php';
require_once 'Zend/Log/Writer/Stream.php';
$logger = new Zend_Log(new Zend_Log_Writer_Stream('php://output'));
$this->_directives['logger'] = $logger;
/**
* Log a message at the WARN (4) priority.
*
* @param string $message
* @throws Zend_Cache_Exception
* @return void
*/
protected function _log($message, $priority = 4)
if (!$this->_directives['logging'])
return;
if (!isset($this->_directives['logger']))
Zend_Cache::throwException('Logging is enabled but logger is not set.');
$logger = $this->_directives['logger'];
if (!$logger instanceof Zend_Log)
Zend_Cache::throwException('Logger object is not an instance of Zend_Log class.');
$logger->log($message, $priority);
第 66 行的代码说:“ while (list($name, $value) = each($options)) "
它在这样的函数中:
public function __construct(array $options = array())
while (list($name, $value) = each($options))
$this->setOption($name, $value);
注意:我是新学生,学php不是那门课的重点,也没有学过php,所以不知道怎么解决这个问题。
【问题讨论】:
PHProjekt 很长一段时间没有被触及,似乎已经被放弃了。它期待的 PHP 版本比您安装的要旧得多,并且抱怨最近已弃用的旧 PHP 功能。如果您解决了这一问题,您可能会遇到其他问题。您最好的选择可能是使用旧版本的 PHP。 是的,它有不止一个错误,但是,在使用 Barmar 在不同地方给我的解决方案后,在同一个文档和其他地方的不同地方,它是同一种已弃用的功能,我能够进入。也非常感谢你。我确实看到它有很多错误,但最后我能够输入纠正似乎避免我这样做的地方。 【参考方案1】:使用foreach
循环:
foreach ($options as $name => $value)
...
【讨论】:
非常感谢,效果很好。我会赞成你的回答,但我是新来的,所以我没有足够的声誉。以上是关于已弃用:each() 函数已弃用。 C:\xampp\htdocs\phprojekt\library\Zend\Cache\Backend.php 在第 66 行 [重复]的主要内容,如果未能解决你的问题,请参考以下文章
已弃用:each() 函数已弃用。 C:\xampp\apps\magento\htdocs\vendor\colinmollenhour\cache-backend-file\File.php 第