William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

PHP:How to know the server is Windows or Linux?

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‘:

  1. background-color
  2. background-image
  3. background-repeat
  4. background-attachment
  5. 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

css-font-cheat-sheet.jpg

Advertisements

8 responses to “PHP:How to know the server is Windows or Linux?

  1. Jeremiah Journot 10/10/2011 at 9:51 am

    I discovered your blog site on google and test just a few of your early posts. Continue to keep up the very good operate. I simply additional up your RSS feed to my MSN Information Reader. Looking for forward to studying more from you later on!…

  2. bloog 10/12/2011 at 9:43 am

    Thank you for the auspicious writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how could we communicate?

  3. bloog 10/14/2011 at 5:51 am

    I do agree with all the ideas you have presented in your post. They’re really convincing and will definitely work. Still, the posts are too short for beginners. Could you please extend them a little from next time? Thanks for the post.

  4. pressel page 10/15/2011 at 1:46 am

    I like the valuable information you provide in your articles. I’ll bookmark your blog and check again here regularly. I’m quite certain I will learn a lot of new stuff right here! Good luck for the next!

  5. Johnathan Bias 10/15/2011 at 5:52 am

    The subsequent time I learn a blog, I hope that it doesnt disappoint me as much as this one. I mean, I know it was my option to read, but I really thought youd have one thing interesting to say. All I hear is a bunch of whining about one thing that you would repair when you werent too busy looking for attention.

  6. nasze mazury to cud natury 10/16/2011 at 2:00 pm

    Hello There. I found your blog using msn. This is a very well written article. I’ll make sure to bookmark it and return to read more of your useful info. Thanks for the post. I’ll definitely comeback.

  7. blog 10/20/2011 at 4:36 pm

    Normally I don’t read article on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been amazed me. Thanks, very nice post.

  8. powercashadvance.com 10/28/2011 at 10:53 am

    Just about all I can say is, I am not sure what to say! Except of course, for the excellent tips that are shared on this blog. I am able to think of a trillion fun ways to read the posts on this site. I believe I will eventually take a step with your tips on those things I could never have been able to manage alone. You had been so innovative to permit me to be one of those to benefit from your useful information. Please know how great I am thankful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: