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

Pages: 1-4041-

WHY PHP NO WORK

Name: Anonymous 2008-06-18 0:17

DEAR PROG

WHY NO WORK?
SICP WAS NO HELP.

url_setopt($curl, CURLOPT_POSTFIELDS,"name_f="$_POST["username1"]");
url_setopt($curl, CURLOPT_POSTFIELDS,"name_l="$_POST["username2"]");
url_setopt($curl, CURLOPT_POSTFIELDS,"pass0=$_POST["pass"]");
url_setopt($curl, CURLOPT_POSTFIELDS,"pass1=$_POST["pass"]");
url_setopt($curl, CURLOPT_POSTFIELDS,"email=$_POST["email"]");

Name: Anonymous 2008-06-18 0:25

i sage'd

Name: Anonymous 2008-06-18 0:27

>>2

; _ ;

curl_setopt($curl, CURLOPT_POSTFIELDS,"name_f=$_POST["username1"]");

unexpected T_VARIABLE

feeeeeeeex it

Name: Anonymous 2008-06-18 0:31

>>3
"name_f=$_POST["username1"]"
How do I nested quotes?

Name: Anonymous 2008-06-18 0:36

>>4

I don't know ; _ ;

Maybe I should go back to where I rock.
Pascal.
Fuck year.

Name: Anonymous 2008-06-18 4:29

GO THE FUCK AWAY RAGE RAGE RAAAAAAAAAAAAAGE

Name: Anonymous 2008-06-18 18:46

curl_setopt($curl, CURLOPT_POSTFIELDS,"name_f=$_POST['username1']");

etcetc, gtfo noob

Name: Anonymous 2008-06-18 21:33

>>7
Concatenation is faster than interpolation.

curl_setopt($curl, CURLOPT_POSTFIELDS, "name_f=" . $_POST['username1']);

Name: Anonymous 2008-06-18 21:37

>>8
' is faster than " because " needs to process the string for potential interpolation.

curl_setopt($curl, CURLOPT_POSTFIELDS, 'name_f=' . $_POST['username1']);

Name: Anonymous 2008-06-18 21:41

>>9
Only the first time the script is loaded.

Name: Anonymous 2008-06-19 3:07

curl_setopt($curl, CURLOPT_POSTFIELDS,
  'name_f=' . $_POST['username1'] .
  '&name_l=' . $_POST['username2'] .
  '&pass0=' . $_POST['pass'] .
  '&pass1=' . $_POST['pass'] .
  '&email=' . $_POST['email']);

Name: Anonymous 2008-06-19 3:10

Speed, slowest to fastest:

print("Hai $var");
echo "Hai $var";
echo "Hai {$var}";
echo "Hai ${var}";
echo "Hai " . $var;
echo 'Hai ' . $var;
echo 'Hai ', $var;

Name: Anonymous 2008-06-19 3:25

>>9
Does ``compile-time optimization'' say anything to you?

Name: Anonymous 2008-06-19 3:38

>>13
% php <<'EOD'
<?php
$start = microtime(true);
for ($i = 0; $i !== 100000; ++$i) {
        $a = "Hai..";
}
echo "1: " . (microtime(true) - $start) . "\n";

$start = microtime(true);
for ($i = 0; $i !== 100000; ++$i) {
        $a = 'Hai..';
}
echo "2: " . (microtime(true) - $start) . "\n";
?>
EOD
1: 0.047648191452
2: 0.0441718101501
%

Name: Anonymous 2008-06-19 4:08

this thread reminds me of something...
slow:
Console.WriteLine("Hello, {0}.", name);

faster:
{
 StringBuilder sb = new StringBuilder("Hello, ", 8 + name.Length);
 sb.Append(name);
 sb.Append(".");
 Console.WriteLine(sb.ToString());
 sb.Finalize();
}


fastest:
Console.WriteLine("Hello, " + name + ".");

but...
slow:
string s = "x";
for(int i = 0; i < 31; ++i)
 s = String.Format("{0}{1}", s, s);


faster:
string s = "x";
for(int i = 0; i < 31; ++i)
 s += s;


even faster:
StringBuilder sb = new StringBuilder("x", 0x7fffffff);
for(int i = 0; i < 31; ++i)
 sb.Append(sb.ToString());
string s = sb.ToString();


fastest:
string s = new String('x', 0x7fffffff);

Name: Anonymous 2008-06-19 4:14

Faster than fastest:
string s = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

Name: Anonymous 2008-06-19 4:17

>>16
doesn't do the same thing.
31 != 2147483647

Name: Anonymous 2008-06-19 4:17

>>16
Never mind, I suck dick.

Name: Anonymous 2008-06-19 4:59

To make up for my fail, more performance:

Slower:
if (streln($str) >= 5) // ...
Faster:
if (isset($str[5])) // ...

Slower:
// ... lots of code that may set $var
if (isset($var)) // ...
Faster:
$var = null;
// ... lots of code that may set $var
if ($var !== null) // ...

Surprisingly, equal:
empty($e) === (Bool) $e // the latter gives an error if $e is unset, tho.

Slower:
$e="eval(\"\$e\");";
eval($e);
Faster:
for(;;);

Obvious:
preg_replace("/whut/", "what", $whut) < str_replace("whut", "what", $whut);

Teh sux:
$var = "myprop" . $id;
$class->$var[5]; // Buggy, too.
Teh win:
$class->{"myprop" . $id}[5];

Should work, but doesn't:
{"func" . $i}(); // $this->{"func" . $i}(); works.

Name: Anonymous 2008-06-19 5:00

>>19
No, that's not faster.
That's buggier.

Slower:
if (streln($str) >= 5) // ...
Faster:
if (isset($str[5])) // ...

this is wrong if the length of the string is 5.

HOH GOD THE FUCKING FAIL I WANT TO FUCKING HIT YOU
I HATE YOU

Name: Anonymous 2008-06-19 5:01

>>19
plus, strlen() is not O(n) in PHP. It's O(1).

Name: Anonymous 2008-06-19 5:01

forgot my sage

Name: Anonymous 2008-06-19 5:06

>>21
It should be O(1) in C too, but they made a retarded implementation back in the day and now we're stuck with it.

Name: Anonymous 2008-06-19 5:18

What have I started...

Name: Anonymous 2008-06-19 5:22

>>16
oops...
2147483647 != 2147483648
easily fixed:
StringBuilder sb = new StringBuilder("x", 0x80000000)
and
string s = new String('x', 0x80000000);

i haven't tested it, but filling 4GB (characters in c# are 16 bits) of memory with a single 16-bit value is almost certainly faster than reading 4GB from a file into memory.

Name: Anonymous 2008-06-19 5:24

HOW DO I CHANGE A SECTION OF A FILE IN C

Name: Anonymous 2008-06-19 5:25

>>26
OMG YOU HAVE TO REWRITE THE WHOLE THING

Name: Anonymous 2008-06-19 5:25

>>27
OH WOW OKAY THANKS I'LL GO KILL MYSELF

Name: Anonymous 2008-06-19 5:28

>>26
You load the file, or at least the part you are interested in, in memory, you do the necessary manipulations and you write it back.

Name: Anonymous 2008-06-19 5:41

>>23
int strlen(char *s){
 return rindex(s, 0);
}

Name: Anonymous 2008-06-19 5:50

>>30
rindex is some sort of hash lookup?
O(1), sure.

Name: Anonymous 2008-06-19 5:59

>>31
rindex finds the last occurrence of a character, in this case 0, in a string. It's O(n).

Here's an O(1) strlen in C:
size_t strlen(const char *s){
 return *(char *)s = 0;
}


POSIX doesn't say strlen can't modify the string!

Name: Anonymous 2008-06-19 6:10

>>23
Wrong, it shouldn't be O(1) in C.
If you can't write your own damn string library you're not worthy of being a C programmer. And no, you don't have to. You could just use a library already written by someone smarter than you.
>>32
It does, as does ISO C you fucking incompentent programmer.
NOTICE THE GOD DAMN "const char" PART. MORON. IMBECILE. CRETIN. I FUCKING HATE YOU.

Name: Anonymous 2008-06-19 6:53

It does, as does ISO C you fucking incompentent programmer.
"If an attempt is made to modify an object defined with a const-qualified type through use
of an lvalue with non-const-qualified type, the behavior is undefined. If an attempt is
made to refer to an object defined with a volatile-qualified type through use of an lvalue
with non-volatile-qualified type, the behavior is undefined.113)"

"undefined" means that ISO C doesn't say that it can't modify the string.
Also, POSIX doesn't say you can't do this:
#define const /* lol */

Name: Anonymous 2008-06-19 7:28

>>33
Yes it should. Making strings simply a null-terminated character array was a bad design decision.

Name: Anonymous 2008-06-19 7:53

>>20
Yeah, yeah, I had an = too much.
(strlen($x) > $y) === isset($x[$y])

>>21
Fucking faggot.

% php <<'EOD'
<?php
$n = 10000000; $str = "Hi there.";
$start = microtime(true);
for ($i = 0; $i !== $n; ++$i) {
        $a = (strlen($str) > 6);

}
echo "1: " . (microtime(true) - $start) . "\n";

$start = microtime(true);
for ($i = 0; $i !== $n; ++$i) {
        $a = isset($str[6]);
}
echo "2: ". (microtime(true) - $start) . "\n";
?>
EOD
1: 2.4390909671783
2: 0.94741892814636
% php <<'EOD'
<?php
$n = 10000000; $str = str_repeat("a", 20000);
$start = microtime(true);
for ($i = 0; $i !== $n; ++$i) {
        $a = (strlen($str) > 20000);

}
echo "1: " . (microtime(true) - $start) . "\n";

$start = microtime(true);
for ($i = 0; $i !== $n; ++$i) {
        $a = isset($str[20000]);
}
echo "2: ". (microtime(true) - $start) . "\n";
?>
EOD
1: 2.6805958747864
2: 0.92655682563782

Name: Anonymous 2008-06-19 7:53

>>35
Yeah, C had a lot of bad design decisions that we only realised later on.

Name: Anonymous 2008-06-19 9:01

>>37
Yeah, C had a lot of bad design decisions that we only realised later on.

LAWL

Name: Anonymous 2008-06-19 9:18

>>38
I'm sure he meant 66we99 as in 66the worldwide community of programming professionals and researchers99, of which /prog/ is clearly an eminent member.

Name: Anonymous 2008-06-19 11:47

>>35
No it was not.

Name: Anonymous 2008-06-19 21:17

>>41
Yes it was.

Name: Anonymous 2009-07-12 6:37

>>11
GREAT OF ALL MADE I YOU MEMES

Name: Anonymous 2011-02-04 12:27

Name: Anonymous 2011-02-17 20:20

that's cool and all, but check my doubles over there

Name: Sgt.Kabukiman돀 2012-05-24 6:15

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: bampu pantsu 2012-05-29 3:54

bampu pantsu

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