PHP sucks dick through a straw

Peter Corlett abuse at cabal.org.uk
Fri Jan 12 11:28:52 GMT 2007


On Thu, Jan 11, 2007 at 04:42:21PM -0500, Jeff Anderson wrote:
[...]
> $object->attribute;
> $object->method();

> So if i call some method $object->has_foo() and forget to add the parens
> (thinking that it is an attribute) then PHP will not throw any kind of
> error, and instead just return undef since $object->has_foo was never set.

It's just a Perl artifact that you can omit parentheses on parameterless
function calls. It means something different in C too:

abuse at jalfrezi:~$ cat mad.c
#include <stdio.h>

int forty_two(void) {
  return 42;
}

int main(void) {
  printf("forty_two = %d\n", forty_two);
  printf("forty_two() = %d\n", forty_two());

  return 0;
}
abuse at jalfrezi:~$ gcc -omad mad.c
abuse at jalfrezi:~$ ./mad
forty_two = 134513540
forty_two() = 42
abuse at jalfrezi:~$ 

At least a good C compiler has the sense to point out you've cocked up if
you bother to enable warnings:

abuse at jalfrezi:~$ gcc -Wall -o mad mad.c
mad.c: In function `main':
mad.c:8: warning: int format, pointer arg (arg 2)

although given how many FOSS projects provide page upon page of gcc
warnings, I suspect that they're not taken notice off nearly as often as
they ought to be.



More information about the london.pm mailing list