TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-05-2010, 05:13 PM   #1 (permalink)
The Wanderer
 
Join Date: Jul 2010
Posts: 17
Thanks: 0
Arictos is on a distinguished road
Default 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!
PHP Code:
echo 3
As before, don't attempt the simplest method possible, but most inventive! See what you can come up with.
  1. eval and create_function functions are disallowed.
  2. 8 lines maximum but lines with only { and } on do not count towards that total. This does not include any echoes of the value.
  3. 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.
  4. 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)
  5. 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.
Arictos is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
The most inventive way to switch 2 values Wildhoney Tips & Tricks 32 08-10-2010 05:10 AM
How to get row number from 2 top numberd rows ttmtake General 5 01-28-2009 11:16 PM
Sorting number reversed problem... Peuplarchie General 2 01-21-2009 08:04 PM
Unique random number? code_junkie Advanced PHP Programming 4 12-21-2008 12:01 AM
how to get the rows affected(not number of rows) kororo203 Absolute Beginners 2 04-23-2008 08:32 AM


All times are GMT. The time now is 09:18 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design