 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
07-05-2010, 05:13 PM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jul 2010
Posts: 17
Thanks: 0
|
The most inventive way to get the number 8
So, the other thread had a bit of fun behind it, so I figured maybe try starting another, similar thread? This one will be based around getting the number 8.
I'll follow the same structure from the other thread.
This would be the simplest method to get this answer, however be sure to read the rules!
As before, don't attempt the simplest method possible, but most inventive! See what you can come up with. - eval and create_function functions are disallowed.
- 8 lines maximum but lines with only { and } on do not count towards that total. This does not include any echoes of the value.
- You must have only one semi-colon per line (;) unless of course it's used elsewhere apart from indicating the end of a line. Thus you're not allowed to fuse 2 lines together into 1. The exception is a for loop to where you're allowed 2.
- If PHP is going to store an integer in a variable (which I assume a lot of situations will) PHP will have to discover that number. An exception to this rule is the for loops first and last expressions. (Added this rule to make things a bit more entertaining)
- No PHP errors may be displayed. This includes Notices, Warnings, anything. error_reporting(-1); The only thing that can output is the number 8.
So however you end up doing it, the code must output the number 8.
I'll start off with two examples to show the diversity in which rules can be followed, although i'm sure many people will come up with their own interpretations!
PHP Code:
$var = 'I\'m the cookie monster!'; $var = strpos($var, "cookie");
echo $var;
PHP Code:
$string = 'aardvark'; $count = (int) false; for($i = 0; $i < strlen($string); $i++) $count++;
echo $count;
Last edited by Arictos : 07-05-2010 at 05:44 PM.
|
|
|
|
07-05-2010, 06:03 PM
|
#2 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Assuming our file is this
PHP Code:
<?php $image = 'myfile.jpg'; $degrees = 90; header('Content-type: image/jpeg') ; $source = imagecreatefromjpeg($image) ; $rotate = imagerotate($source, $degrees, 0) ; imagejpeg($rotate) ; ?>
|
|
|
|
07-05-2010, 06:05 PM
|
#3 (permalink)
|
|
The Wanderer
Join Date: Jul 2010
Posts: 17
Thanks: 0
|
Lol, that's just awesome, but it did break a rule ;) You defined degrees as a number ;)
But regardless, it was a great submission.
|
|
|
|
07-05-2010, 06:10 PM
|
#4 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
Whoops, I'll fix that
Here we go:
Assuming our file is this
PHP Code:
<?php $image = 'myfile.jpg'; $degrees = intval('90'); header('Content-type: image/jpeg') ; $source = imagecreatefromjpeg($image) ; $rotate = imagerotate($source, $degrees, 0) ; imagejpeg($rotate) ; ?>
ps. If you think that is a cheap way, my next alternitave would be to add 9 int typecast trues together.
|
|
|
|
07-05-2010, 07:39 PM
|
#5 (permalink)
|
|
The Wanderer
Join Date: Jul 2010
Posts: 17
Thanks: 0
|
I don't think that's a cheap way at all x] You didn't directly assign the value, which is completely valid according to the original rules :)
But that being said, hopefully we can see some pretty crazy ways to get the numbers :)
I still like your idea though, it was very creative.
|
|
|
|
07-05-2010, 10:38 PM
|
#6 (permalink)
|
|
The Addict
Join Date: Aug 2008
Posts: 336
Thanks: 8
|
I think I might have done some cheating, but this is my take.
this is using php 5.3 of course
|
|
|
|
07-06-2010, 05:10 AM
|
#7 (permalink)
|
|
The Wanderer
Join Date: Jul 2010
Posts: 17
Thanks: 0
|
You did awesome :) But you don't have to intval your $var's, they're already being interpreted by PHP. I'm excited to see what other methods, other than intval people can come up with :)
|
|
|
|
07-06-2010, 08:51 PM
|
#8 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
I got bored.
PHP Code:
<?php for( $PHP =FUNCTION( $A,$AA){$Y ="CHR";$XX =$A .${ "AA" };$N =ord (${ "X" ."X" }[$A [1]] +4- +4) ;$Z= 0x08 +$N; return$Y($Z );},print( $PHP (":)" ,+8));0;); ?>
|
|
|
|
07-07-2010, 02:46 AM
|
#9 (permalink)
|
|
The Wanderer
Join Date: Jul 2010
Posts: 17
Thanks: 0
|
I don't want even to begin to understand what's going on.
But it looks fancy ;P
|
|
|
|
07-07-2010, 03:40 PM
|
#10 (permalink)
|
|
The Addict
Join Date: Aug 2008
Posts: 336
Thanks: 8
|
awesome salathe, that is a great presentation.
|
|
|
|
07-07-2010, 07:01 PM
|
#11 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
Quote:
Originally Posted by Arictos
I don't want even to begin to understand what's going on.
|
What it's actually doing is very simple, it is just presented in an obfuscated way to get the VIII. Here's what it really does: print chr(56); 
|
|
|
|
07-15-2010, 11:00 PM
|
#12 (permalink)
|
|
The Addict
Join Date: May 2009
Posts: 287
Thanks: 5
|
PHP Code:
if ($_GET['count'] == 8) { echo $_GET['count']; } else { if ($_GET['count'] > 8) { header("Location: index.php?count=0"); } else { header("Location: index.php?count=" . $_GET['count']++); } }
|
|
|
|
07-16-2010, 01:49 AM
|
#13 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
If you know your ASCII talkphp => 116 + 97 + 108 + 107 + 112 + 104 + 112 => 756, Drop the 7 and you have 56. 8's ascii code.
Last edited by Enfernikus : 07-17-2010 at 03:42 PM.
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|