本文整理汇总了PHP中OS::isWindows方法的典型用法代码示例。如果您正苦于以下问题:PHP OS::isWindows方法的具体用法?PHP OS::isWindows怎么用?PHP OS::isWindows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OS
的用法示例。
在下文中一共展示了OS::isWindows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bold
public static function bold($message)
{
if (!OS::isWindows()) {
echo "[1m";
}
echo $message;
if (!OS::isWindows()) {
echo "[m";
}
}
示例2: deleteContents
/**
* deleteContents of a folder recursively, but not the folder itself.
*
* On Windows systems this will try to remove the read-only attribute if needed.
*
* @param string $path Path of folder whose contents will be deleted
*
* @throws \RuntimeException Thrown when something could not be deleted.
*/
public static function deleteContents($path)
{
if (!is_dir($path)) {
return;
}
/** @var \SplFileInfo[] $files */
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $fileInfo) {
if ($fileInfo->isDir()) {
if (@rmdir($fileInfo->getRealPath()) === false) {
throw new \RuntimeException(sprintf("Unable to delete child folder '%s' in '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
}
} elseif (@unlink($fileInfo->getRealPath()) === false) {
if (OS::isWindows()) {
Exec::create('attrib', '-R', $fileInfo->getRealPath())->run();
if (@unlink($fileInfo->getPathname())) {
continue;
}
}
throw new \RuntimeException(sprintf("Unable to delete file '%s' in folder '%s': %s", $fileInfo->getFilename(), $fileInfo->getPathname(), error_get_last()['message']));
}
}
}
示例3: escapeArgument
/**
* @param string $argument
*
* @return string
*/
private function escapeArgument($argument)
{
// Always escape an empty argument so it doesn't get lost.
if ($argument === '') {
return escapeshellarg($argument);
}
if (!OS::isWindows()) {
return $this->escapeLinuxArgument($argument);
}
return $this->escapeWindowsArgument($argument);
}