PHP:How to know the server is Windows or Linux?
Blogs20112011-10-04
PHP: How to know the server is Windows or Linux?
A simple function to judge the running environment: Is the script running in Windows or Linux?
This is useful for PHP script compatible: Codeing and Testing in local Windows environment, such as Windows XAMPP; while formly running in Linux production server. Here is the script:
function get_env() {
if(isset($_SERVER['SERVER_SOFTWARE'])) {
if(preg_match('/Win32/i', $_SERVER['SERVER_SOFTWARE']))
return 'Windows';
return 'Unix';
}
}
// In the top of the script:
if(get_env()=='Windows')
define('PATH', '.windows_dir');
else
define('PATH', './linux_dir/');CSS: Shorthand of background
CSS’s ’background’ attribute has many options. The following lists these options and gives examples to use the shorthand property of ’background‘:
- background-color
- background-image
- background-repeat
- background-attachment
- background-position
body {background:#ffffff url('img_tree.png') no-repeat right top;}
background:#5d9ab2 url('img_tree.png') no-repeat top left;
$(element)..css({'background-color': '#ffe', 'border-left': '5px solid #ccc'})Similiar, for font:
| Property | Description |
|---|---|
| font | Sets all the font properties in one declaration |
| font-family | Specifies the font family for text |
| font-size | Specifies the font size of text |
| font-style | Specifies the font style for text |
| font-variant | Specifies whether or not a text should be displayed in a small-caps font |
| font-weight | Specifies the weight of a font |

