CSTrüter HomeArticlesDownloadsAbout meContact me
a quick look at how to create a windows service using C# 2010-02-28 21:48:06
How to call server-side code from client-side code, using PageMethods in ASP.net 2010-02-21 12:31:27
How to pass a set of data to an xml type in SQL 2005/8 2010-02-12 19:04:23
Some funky behaviour regarding overload Resolution of dynamic/object types 2010-02-09 17:16:52
Object orientated programming within JavaScript 2010-01-28 07:25:45
How to sort data using ASP.net (C#) and SQL 2005/8 2010-01-18 15:23:14
Quick look at some of the new features added to C# 4.0 2010-01-12 21:52:13
SQL 2008 introduced a nifty feature called Table-Valued Parameters (TVP) into its codebase 2010-01-06 22:58:25
How to page data using ASP.net (C#) and SQL 2005/8 2009-10-19 15:01:45
a post about sql joins 2009-09-20 15:50:57
Creating a WYSIWYG textbox for your website is actually quite simple. 2007-02-01 12:00:00
Move items between two listboxes in ASP.net(C#, VB.NET) and PHP 2008-06-12 17:07:43
Firefox word wrapping issues 2008-06-09 09:51:21
2007-02-22 12:00:00
Blog about passing parameters by reference to functions using func_get_arg(s) 2008-07-27 12:38:24
This one is for the PHP enthusiasts, most of you are hopefully probably aware of this, but if you're not (and for people that adhere to other perhaps more sane languages), the following condition will evaluate to true and output the text, "How dodgy is this?" if (2 == "2abc") { echo "How dodgy is this?"; } The reason for this can be found in the way that PHP handles conversion/casting of its types. PHP will automatically convert the string ("2abc") to an integer to allow comparison of the values (the joys of loosely typeness). Which brings me to the next expression which gives us a clue of what's really happening. $a = (int) "2abc"; echo $a; The non numeric part of the variable will be stripped away, leaving us with an integer value (if the string begins with a numeric value that is) - personally I believe this is horrible functionality - a variable containing non numeric values must NOT be allowed to be converted to an integer in this manner, conversion must fail. Getting back to our if condition at the top, PHP introduced "identity" operators into their codebase in version 4 (I believe), observe: if (2 === "2abc") { echo "How dodgy is this?"; } This condition will evaluate to false and won't output anything, the reason being that instead of converting the variables we're attempting to compare, it compares the inferred types of each variable and only then the actual content of the variables. In my opinion this is more credible (robust/safe) behaviour for an equality operator, not to mention to all the other operators in PHP that work in the same fashion (which might be too strict for a lot of PHP devs, something more familiar to strongly typed languages like C#). One could argue that since PHP is a loosely typed language, one should rather implement some sane behaviour in the way PHP handles certain conversions and still allow PHP to convert values automatically to make them compareable. This is exactly how javascript (another loosely typed language) handles scenarios like this. The following condition will evaluate to false like expected. if (2 == "2abc") { alert('True'); } Unlike the identity operators in PHP, the following will evaluate to true, but since type conversion seems to be more sane in javascript, it doesn't matter, they might not be equal in type, but they are definitely equal in value. if (2 == "2") { alert('True'); }
if (2 == "2abc") { echo "How dodgy is this?"; }
$a = (int) "2abc"; echo $a;
if (2 === "2abc") { echo "How dodgy is this?"; }
if (2 == "2abc") { alert('True'); }
if (2 == "2") { alert('True'); }
Hhahaha, you're quite the rebel! I guess to each his own? I am actually planning to write an ebook soon called salvaging PHP, where I am going to go through all the "difficulties" in PHP - hopefully helping devs to create more robust code within the PHP realm.
C'mon lad, is that all you have???, I have been using php, and well....simply it rules!, not like the .NET environment where you are caught in rules!!
Hahah, what can I say? PHP is the toypom of the programming world! ;)
No Reply??
Someone is having a crack at php again!!!!
Codebooth my semi-community site etc (work in progress)
The company I'am currently working for as software developer.
a Parallel reference of programming languages 2009-09-10 12:48:23
a tutorial explaining how to develop a simple login using PHP and MySQL 2009-09-05 18:26:47
An article looking at adding some kind of event driven model to PHP 5 2008-07-28 12:48:09
It is very simple creating your own rss reader, the following article looks at a few methods of doing this. 2008-06-23 13:18:25
A quick reference about working with dropdown boxes (select element) in javascript. 2007-02-17 16:36:41
Collection of funny programming articles 2006-10-08 14:23:43