Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP WTFs

Name: Anonymous 2013-03-20 18:58

http://php.net/manual/en/function.shuffle.php
This function shuffles (randomizes the order of the elements in) an array.
Returns TRUE on success or FALSE on failure.


How can a shuffle fail?

Name: Anonymous 2013-03-20 19:01

if you choose php for your proyect you fail as a decent human being

Name: Anonymous 2013-03-20 19:06

In PHP everything can fail.

Name: Anonymous 2013-03-20 19:08

THAT WAS PHP QUALITY!

Name: Anonymous 2013-03-20 19:17

Circular lists
Oh wait, PHP doesn't have those!

There's also this, which (in a fit of sanity) is apparently being deprecated.
http://www.php.net/mysql_real_escape_string

Name: Anonymous 2013-03-20 20:35

>>5
Deprecated in favour of the ``i'' version.
http://www.php.net/manual/en/mysqli.real-escape-string.php

Name: Anonymous 2013-03-20 20:51

>>6
and now they have two problems.

Name: Anonymous 2013-03-20 21:56

but php arrays are all hash tables. whats the point to shuffle a hash table?

Name: Anonymous 2013-03-20 22:16

>>8
At that moment, Sussman was enlightened

Name: Anonymous 2013-03-21 16:18

http://php.net/manual/en/function.echo.php
echo is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo, the parameters must not be enclosed within parentheses.

What in the name of fuck? Why does that exist?

And why there is http://php.net/manual/en/function.print.php
Returns 1, always.

what is the point of always returning 1?

Name: Anonymous 2013-03-21 16:23

>>10
Why doesn't PHP have a 3D print function yet?

Name: Anonymous 2013-03-21 16:32

http://en.wikipedia.org/wiki/PHP_syntax_and_semantics
Function calls may be made via variables, where the value of a variable contains the name of the function to call.

Did they specially crafted that to allow some idiot to call any function based on user-input or Intel paid them, so that efficient compilation wont be possible?

Name: Anonymous 2013-03-21 16:33

>>10
Python also has it, ironically it is called print

Name: Anonymous 2013-03-21 16:35

>>13
the ultimate fuckall would be if Python also had an echo function

Name: Anonymous 2013-03-21 16:36

>>13
Wasn't that changed with 3.0?

Name: Anonymous 2013-03-21 16:36

>>12
They did it because they are idiots and couldn't figure out how to support function references.

Name: Anonymous 2013-03-21 16:41

http://en.wikipedia.org/wiki/PHP#Functions
True anonymous functions are supported using the following syntax:
function($y) use ($x) {

Wut? Isn't the whole point of lexical closures is to automate variable capture process?

http://www.tuxradar.com/practicalphp/18/1/10
PHP performs garbage collection ... When you tell it to
that is just WTF?!!

Name: Anonymous 2013-03-21 16:44

>>17
capture
That is so sexist! Haven't you thought of all those poor women who were captured and raped by savage men all around the world?!

Name: Anonymous 2013-03-21 16:50

>>17
Unlike the other scripting languages, PHP knows its lexical scoping design is retarded compared to Scheme. See: http://dis.4chan.org/read/prog/1347852684

Name: Anonymous 2013-03-21 17:17

Failing a shuffle is not normal. But on PHP it is.

Name: Anonymous 2013-03-21 18:47

>>19
http://www.reddit.com/r/programming/comments/zx137/coffeescript_devs_dont_understand_lexical_scope/
Jesus F. Christ! CoffeeScript introduces more problems, than it solves.

While JavaScript already has more than one way to do it:
if (C) {T} else {E}
C ? T : E
(C && T) || (!C && E)


CoffeeScript bloats it even more:
T if C
if C then T else E

if C
  T
else
  E


and of course you can do arithmetics in strings, just generate more confusion:
Shit + Crap # does this code works with numbers or strings?

Finally, CoffeeScript has this faggy hipster forced indentation of code.

Name: Anonymous 2013-03-21 18:55

Jesus F. Christ!
It's Jesus H. Christ, you pleb.

Name: Anonymous 2013-03-21 18:56

>>22
YHBT. YHL. HAND.

Name: Anonymous 2013-03-21 19:03

>>21
And they even present it as a "feature": http://minus.com/lSBsHWnwUvTor

Name: Anonymous 2013-03-21 21:35

>>1
it failed to shuffle? Fat Man Scoop and Crooklyn ClaaAN!

Name: Anonymous 2013-03-21 22:07

>>10,13
awk was probably the first to do this. Perl does too. It's a terrible design decision.

>>21
Further evidence to the claim that web languages are a ghetto.

Name: Anonymous 2013-03-21 23:03

>>26
>not having a clue
>trying to sound clever
>LLLLLLLLEEEEEEEEELLLLLLLLLLLLLLLLLLLLLLLLLL

Name: Anonymous 2013-03-22 0:01

>>26
Further evidence to the claim that web languages are a ghetto.
What did you expected from a person named Jeremy Ashkenas[1]?

1. http://en.wikipedia.org/wiki/Ashkenaz

Name: Anonymous 2013-03-22 0:09

>>26

At least AWK has a perfectly sane printf() function as well.

Its print statement is a convenience feature, since it is often used to write one-liners.

Name: Anonymous 2013-03-22 0:34

In fact, considering all these "CoffeeScripts", even Java looks not so bad. Yes, Java is verbose and inflexible, but Java has solid scoping rules, which save a lot of time and money, you spend debugging the CoffeeScript vomit.

Name: Anonymous 2013-03-22 1:06

this is how


$php -r "$a = array(); var_export(shuffle($a));"
true

$php -r "$a = false; var_export(shuffle($a));"
[22-Mar-2013 18:05:10] PHP Warning:  shuffle() expects parameter 1 to be array, boolean given in Command line code on line 1

false

$php -r "$a = 1.337; var_export(shuffle($a));"
[22-Mar-2013 18:05:19] PHP Warning:  shuffle() expects parameter 1 to be array, double given in Command line code on line 1

false

Name: Anonymous 2013-03-22 1:56

>>31
That is even worse. Why won't it produce error and stop the server, before more damage is done?

Name: Anonymous 2013-03-22 2:05

>>5 SET DA CDR SET DA CDR SET DA CDR!

RIGHT IN DA CUDDER

Don't change these.
Name: Email:
Entire Thread Thread List