-
My Very First Program!
[b]My Very First Output[/b]
I would like to share with you the very first output I created in PHP. This is the easiest output you can create using PHP! New coders are **.*% successful when writing a program such as to function just as this one does. If you can not duplicate this output, please give up trying to code... You are completely hopeless. Confused? You should be! :cool: SORRY! You do not get any notes :cool:
[php]
<?
$fill_array=array(
"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0",
"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0",
"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"
);
$bits= array(
"00","0*","*0","**"
);
$locations= array(
"00" => array(
"0*", "0*", "**", "*5", "20",
"22", "2*", "*4", "**", "4*",
"44", "46"
),
"0*" => array(
"00", "04", "06", "07", "08",
"*2", "*6", "24", "25", "26",
"28", "*2", "*6", "40", "42",
"47"
),
"*0" => array(
"02", "05", "0*", "**", "*7",
"2*", "2*", "*5", "*7", "4*",
"45"
),
"**" => array(
"*0", "*4", "*8", "**", "27",
"*0", "**", "**", "*8"
)
);
while(isset($bits[0])){
$random_num=rand(0,(count($bits)-*));
$random_bit=$bits[$random_num];
$random_location=rand(0,(count($locations[$random_bit])-*));
$fill_array[(int)$locations[$random_bit][$random_location]]=$random_bit;
unset($locations[$random_bit][$random_location]);
$locations[$random_bit]=array_values($locations[$random_bit]);
if(count($locations[$random_bit])==0){
unset($locations[$random_bit]);
$locations[$random_bit]=array_values($locations[$random_bit]);
unset($bits[$random_num]);
$bits=array_values($bits);
}
}
$binary=implode("",$fill_array);
$i=*;$bits=NULL;
while(isset($binary[$i-*])){
$bits .= $binary[$i-*];
if($i%8==0){
print_r(chr(bindec($bits)));
$bits=NULL;
}
$i++;
}
?>
[/php]
-
Wouldn't it have been easier to write:
[code]print "Hello World!";[/code]
???
Mr. Complicated!
LOL
I get many notices and warnings trying to run it using PHP v4.4.4
I get:
[code]
Notice: Undefined index: *0 in D:\inetpub\wwwroot\TESTS\test.php on line 45
Warning: array_values() [function.array-values]: The argument should be an array in D:\inetpub\wwwroot\TESTS\test.php on line 45
Notice: Undefined index: 00 in D:\inetpub\wwwroot\TESTS\test.php on line 45
Warning: array_values() [function.array-values]: The argument should be an array in D:\inetpub\wwwroot\TESTS\test.php on line 45
Notice: Undefined index: ** in D:\inetpub\wwwroot\TESTS\test.php on line 45
Warning: array_values() [function.array-values]: The argument should be an array in D:\inetpub\wwwroot\TESTS\test.php on line 45
Notice: Undefined index: 0* in D:\inetpub\wwwroot\TESTS\test.php on line 45
Warning: array_values() [function.array-values]: The argument should be an array in D:\inetpub\wwwroot\TESTS\test.php on line 45
[/code]
-
Update your PHP :cool: ...
Notice its throwing those notices every time it completely empties an array. 00,0*,*0,**.
The array is empty on PHP4 and cannot array_values() because there are no values in the array. PHP5 Accepts this and does not throw any warnings.
-
SyntaX, you've been dabbling in code obfuscation [I]way [/I]too long... :eek:
-
Forget syntax******, I think I'll create a new account for SynTobfuscator!
-
Don't you have a network admin job? Even as an unemployed adolescent, I wouldn't have enough time to write random code just to flex my coding skills.
Nice code in any case.
-
Its array awareness week. I'm just celebrating! So where is your array? Your not invited without one...
Actually I was just learning the behaviors of different types of arrays, and how to move values around without completely destroying your array structure. Its harder than you think, but more useful than you think.
-
So in other words, a slow day at work ;).
Did you look up each ASCII character's decimal equivalent? I imagine that'd take quite some time, unless you have the entire ASCII table memorised. That would be a cool skill.
-
Work? Whats work? I dont ever work. Its all play.
Well, I know that a space is "*2", "A" starts at 65 and "a" starts at *7... and I can add :cool:
Oh yeah theres that explanation point... had to look that one up.
-
Pedantic Fussbudget Me
[QUOTE=SyntaX******;2*2*0]Work? Whats work? I dont ever work. Its all play.
Well, I know that a space is "*2", "A" starts at 65 and "a" starts at *7... and I can add :cool:
Oh yeah theres that explanation point... had to look that one up.[/QUOTE]
[b]WORK !???[/b]
Obviously, the BBS obscenity filter is NOT working.
LOL
Perhaps these two native PHP functions could prove useful:
[code]
print ord("a"); // Print ASCII code of character "a"
print chr(65); // Print character corresponding to ASCII code 65
[/code]
A quick and simple ASCII table:
[code]
$out = "DEC\tCHR\tHEX<BR>\n";
for ($i=*2; $i < *2*; $i++)
{
$out .= "$i\t" . chr($i) . "\t" . StrToUpper(DecHex($i)) . "<BR>\n";
}
print "<PRE>$out</PRE>";
[/code]
-
Yeah, I think we need to get that obscenity filter fixed!
I only had to add the chr to the output of the binary bits:
[code]
print_r(chr(bindec($bits)));
[/code]
-
[QUOTE=SyntaX******;2*2*0]
Well, I know that a space is "*2", "A" starts at 65 and "a" starts at *7... and I can add :cool:
[/QUOTE]
That'd be a somewhat awesome party-piece.
You: "I can speak fluent ASCII."
Someone else: "77 *0* ** **6 *** ***"
-
[URL="http://www.encyclopediadramatica.com/images/5/5*/Grammar_Nazi.gif"]I think you mean an exclamation point.[/URL]