PHP to Ruby: Lesson 1

March 14th, 2009

The very basics

The Ruby language is object-oriented. PHP is not object-oriented, but has objects. Ruby’s object-oriented nature results in some areas of it’s syntax to look very much like JavaScript. PHP’s echo is puts in Ruby. PHP uses semicolons. Ruby uses semicolons, but only in specific cases. For clean, readable code, assume you won’t be needing semicolons. Lets being…

The Basics

PHP creates arrays and hashes with the same function array().
1
2
3
4
5
6
# PHP
$array = array('my', 'php', 'array');
$hash = array(
   'my_index'=>'my_value',
   'my_second_index'=>'my_second_value'
);

Ruby handles arrays and hashes separately.

1
2
3
4
5
6
# Ruby
array = ['my','ruby','array']
hash = {
   'my_index'=>'my_value',
   'my_second_index'=>'my_second_value'
}
Read the rest of this entry

Browser specific CSS files

December 3rd, 2008

Browsers render HTML and CSS differently. Box model hacking is too messy. And there are just better ways of solving your cross-browser problems.

If the compatibility issues only exist between Internet Explorer and Firefox/Safari the following should suffice:
1
2
3
4
5
6
7
8
9
10
<!-- Firefox/Safari -->
<link rel="stylesheet" href="/assets/css/style.css" type="text/css" media="screen" />

<!--[if IE 6]>
<link rel="stylesheet" href="/assets/css/style_ie6.css type="text/css" media="screen" />
<![endif]-->

<!--[if IE 7]>
<link rel="stylesheet" href="/assets/css/style_ie7.css" type="text/css" media="screen" />
<![endif]-->
Read the rest of this entry