我想在我的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 phpbrowscapBrowscap;
// 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();
,但我不明白替换它的缓存目录('路径/to/to/to/to/to/the/the/the/dir')是。
您可以在项目的根目录中使用mkdir cache
自己创建缓存目录。然后,只需确保目录由适当的用户/组( www-data fy Apache中的
sudo chown www-data:www-data cache
并确保缓存目录已设置其权限,以允许使用以下方式为该用户读取/写入访问:
sudo chmod 644 cache