-
in_array
Posted on September 28th, 2009 No commentsThe in_array() function in PHP checks if a value exists in an array - returning true if it does, or false otherwise.
The last argument in this function forces a strict type check of the value in PHP. Since Ruby does not consider a Fixnum of 1 and a String of ‘1′ to be the same - it always operates as if the last argument were set to true.
PHP
$my_array = array('a', 'b', 'c', 'd'); if('a', in_array($a), true) { echo 'Found it in the array'; } // => Found it in the array
Ruby
my_array = [ "a", "b", "c", "d" ]; if( my_array.include?('a') ) { puts 'Found it in the array'; } # => Found it in the array
-
include
Posted on April 29th, 2009 No commentsThe include() statement includes and evaluates a specified file. The difference between include() and require() is that require() results in a Fatal Error upon failure, whereas include() does not, it only produces a Warning.
include() is not a function in PHP, it is a language construct.
PHP
include('../config.php');
Ruby
include('../config.rb');
-
require
Posted on April 26th, 2009 No commentsThe require() statement includes and evaluates a specified file. The difference between require() and include() is that require() results in a Fatal Error upon failure, whereas include() does not, it only produces a Warning.
require() is not a function in PHP, it is a language construct.
PHP
require ('../config.php');
Ruby
require ('../config.rb');


