Re: Staff listing

Mrten <[email protected]>
Newsgroups gmane.network.irc.blitzed.web
Message-ID <[email protected]>
Om 12:48 op zaterdag 28 augustus 2004, Philipp Kern:

> As you could see on
> http://cvs.blitzed.org/www.blitzed.org/staff/index.php?rev=1.1&content-type=text/vnd.viewcvs-markup

which reads:

  if (!isset($_GET[id]) && !isset($_GET[nick])) {


why the fuck does no-one ever read the friggin' php-manual?

http://www.php.net/manual/en/language.types.array.php

8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Why is $foo[bar] wrong?

You should always use quotes around a string literal array index. For
example, use $foo['bar'] and not $foo[bar]. But why is $foo[bar]
wrong? You might have seen the following syntax in old scripts:

<?php
$foo[bar] = 'enemy';
echo $foo[bar];
// etc
?>

This is wrong, but it works. Then, why is it wrong? The reason is that
this code has an undefined constant (bar) rather than a string ('bar'
- notice the quotes), and PHP may in future define constants which,
unfortunately for your code, have the same name. It works because PHP
automatically converts a bare string (an unquoted string which does
not correspond to any known symbol) into a string which contains the
bare string. For instance, if there is no defined constant named bar,
then PHP will substitute in the string 'bar' and use that.

8< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

there are a few guidelines to writing php:

* ALWAYS turn up error_reporting() to E_ALL when writing php, and make
  SURE there are no warnings, EVER.

* turn OFF register_globals. if you think you need it, you are a lazy
  bastard and should be shot.

* turn ON safe_mode when programming, it'll make you think about what
  you want to do.

* NEVER trust user input (from $_GET and $_POST), ALWAYS check
  boundaries and CAST if you expect an integer, and ESCAPE strings
  before using them in an SQL query.

* READ THE FUCKING MANUAL! the 'language reference' and 'security'
  part are CHOCK-FULL of good stuff.

* and the above, since noone ever seems to get it right.


remember folks, you learned it on blitzed!

Mrten.
-- 
Denken begint waar weten stopt.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.