TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Python to PHP Translation (http://www.talkphp.com/python-php-translation/)
-   -   Everything for a reason... (http://www.talkphp.com/python-php-translation/4632-everything-reason.html)

Wildhoney 06-27-2009 08:18 PM

Everything for a reason...
 
An entire forum for one of our newest members! How lucky!
http://www.talkphp.com/search.php?do=finduser&u=3595

tony 06-27-2009 08:20 PM

hehe, that's interesting, but why not making it a broad section, like " From XX language to PHP Translation?

Wildhoney 06-27-2009 08:20 PM

'Cause it is not a permanent fixture :-) British sarcasm at its finest!

tony 06-27-2009 08:24 PM

haha oh ok :P

Normo 06-27-2009 08:37 PM

well thats just brilliant...

sketchMedia 06-27-2009 10:21 PM

I lol'd (don't worry, I cleaned it up!)

Village Idiot 06-27-2009 10:54 PM

Very nice.

codefreek 06-28-2009 12:12 AM

Epic .:hehe:.

Salathe 06-28-2009 10:07 AM

I have this Python script, make it PHP!

Python Code:
class Hello:
  @staticmethod
  def world():
    print "Hello World!"

Hello.world()

Kalle 06-28-2009 11:55 AM

Quote:

Originally Posted by Salathe (Post 26237)
I have this Python script, make it PHP!

Python Code:
class Hello:
  @staticmethod
  def world():
    print "Hello World!"

Hello.world()

PHP Code:
<?php
namespace Hello
{
    class World
    {
        public function __invoke()
        {
            echo('Hello World!');
        }
    }
}

$welcome = new Hello\World;
$welcome();

done with our beloved namespace separator! :)

ETbyrne 06-28-2009 04:56 PM

Actually this would make more sense:

PHP Code:

class Hello
{
    static function 
world()
    {
        echo 
'Hello World!';
    }
}

Hello::world(); 


maZtah 06-29-2009 07:30 AM

Great forum! :)

Jim 06-29-2009 08:21 AM

ETbyrne is right, but Kalle's code looks more impressive :P

Salathe 06-29-2009 08:51 AM

Wrong! The correct translation is of course:
PHP Code:

<?php

define
('Hello''Hello World!');
function 
world(){ echo Hello; }

Hello.world();

?>


ETbyrne 06-29-2009 01:03 PM

That's nothing like the Python code at all. Pretty cool trick though!

sketchMedia 06-29-2009 01:29 PM

Quote:

Originally Posted by Salathe (Post 26278)
Wrong! The correct translation is of course:
PHP Code:

<?php

define
('Hello''Hello World!');
function 
world(){ echo Hello; }

Hello.world();

?>


Trust Salathe to come up with something crazy!

Salathe 06-29-2009 01:57 PM

Quote:

Originally Posted by ETbyrne (Post 26288)
That's nothing like the Python code at all. Pretty cool trick though!

I guess the sarcasm was lost on you. Please don't take anything in this thread/sub-forum as serious (Except this reply?) :-)

Quote:

Originally Posted by sketchMedia (Post 26290)
Trust Salathe to come up with something crazy!

I was going to go with const Hello = … instead of the define('Hello'… which would work (as of PHP 5.3) thanks to the namespace support but figured that it would be a little too crazy for today. :-P

tony 06-29-2009 02:06 PM

Salathe, that snippet blows my mind. how does it work? is if using concatenation? WOW :O

sketchMedia 06-29-2009 02:07 PM

Quote:

but figured that it would be a little too crazy for today
haha, indeed it would, I've not had my lunchtime coffee yet!

To be REALLY sarcastic you really should post it without wrapping it in PHP code tags, with some strange indentation to boot!
define('Hello', 'Hello World!');
function world() {
echo Hello;
}Hello.world();

But that would be too cruel!

Wildhoney 06-29-2009 02:55 PM

Haha. You're cruel, you're cruel. But I like it very much :-) !


All times are GMT. The time now is 03:56 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0