我想在我的php项目中使用phpbrowscap。
要创建此类的新对象,我使用以下代码:
/ phpbrowscap follows the PSR-0 standard, so just require the composer autoload
require 'vendor/autoload.php';
// The Browscap class is in the phpbrowscap namespace, so import it
use phpbrowscap\Browscap;
// Create a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');
// Get information about the current browser's user agent
$current_browser = $bc->getBrowser();
但我不明白要替换它的缓存目录(' path / to / the / cache / dir')。
答案 0 :(得分:0)
您可以使用项目根目录中的mkdir cache
自行创建缓存目录。然后确保该目录由适当的用户/组(Apache中默认为 www-data )拥有:
sudo chown www-data:www-data cache
并确保缓存目录的权限已设置为允许该用户使用以下方式进行读/写访问:
sudo chmod 644 cache