Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.
Moderator: General Moderators
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Sat Jun 21, 2003 4:39 pm
Hello everyone. I may be relatively new to PHP, but that doesn't mean that I can't still have some fun with it. My goal is to make the following script more and more complex as people from the community keep adding to it more and more without changing the actual output. Since I am a "newb," I will start off with something simple, but hopefully you guys can elaborate on what I have done. Let's see what you guys can do!
Code: Select all
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
define("THE_FIRST_WORD", "Hello");
$the_second_word = "World";
print THE_FIRST_WORD . " " . $the_second_word . "!";
?>
</body>
</html>
Output (obviously):
Hello World!
m@ndio
Forum Regular
Posts: 163 Joined: Fri Jun 06, 2003 12:09 pm
Location: UK
Post
by m@ndio » Sun Jun 22, 2003 3:36 pm
not a very appropriate post mate
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Sun Jun 22, 2003 3:37 pm
How so?
m@ndio
Forum Regular
Posts: 163 Joined: Fri Jun 06, 2003 12:09 pm
Location: UK
Post
by m@ndio » Sun Jun 22, 2003 4:10 pm
This forum is for people with problems, I just feel it belongs in the "misc" category. But hey! knock yourself out. I think people share my opinon on this, hence probably why you have had no response...
tar
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Sun Jun 22, 2003 4:43 pm
ah, php tennis. We had this before, e.g.
viewtopic.php?t=1668
viewtopic.php?t=1725
why not? But "General Discussion" is probably more appropriate
Code: Select all
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
define("THE_FIRST_WORD", "Hello");
$the_second_word = "Worl" . chr(100);
print THE_FIRST_WORD . " " . $the_second_word . "!";
?>
</body>
</html>
cactus
Forum Regular
Posts: 343 Joined: Tue Jun 10, 2003 4:16 am
Location: UK
Post
by cactus » Sun Jun 22, 2003 4:55 pm
Well, if I must
Code: Select all
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
define("THE_FIRST_WORD", "Hello");
$the_second_word = "Worl" . base64_encode(chr(100));
print THE_FIRST_WORD . " " . substr($the_second_word, 0, 4) . base64_decode(substr($the_second_word, 4)). "!";
?>
</body>
</html>
Regards,
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Sun Jun 22, 2003 9:48 pm
Cool stuff. I understand what you mean now. Maybe this can be moved into another section. Still, however, let's see how far we can take this!!!
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Jun 23, 2003 1:15 am
Code: Select all
<?php header('Content-type: text/html'); ?>
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
define("THE_FIRST_WORD", "Hello");
$the_second_word = "Worl" . base64_encode(chr(100));
print THE_FIRST_WORD . " " . substr($the_second_word, 0, 4) . base64_decode(substr($the_second_word, 4)). "!";
?>
</body>
</html>
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Mon Jun 23, 2003 1:51 am
Fun, fun, fun.
Code: Select all
<?php header('Content-type: text/html'); ?>
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
$the_letter_h = "H";
define("THE_FIRST_WORD", "ello");
$the_second_word = "Worl" . base64_encode(chr(100));
for ($the_h_counter = 0; $the_h_counter < 1; $the_h_counter++)
{
print $the_letter_h;
}
print THE_FIRST_WORD . " " . substr($the_second_word, 0, 4) . base64_decode(substr($the_second_word, 4)). "!";
?>
</body>
</html>
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Jun 23, 2003 2:31 am
Code: Select all
<?php header('Content-type: text/html'); ?>
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
$the_letter_h = "H";
define("THE_FIRST_WORD", "ello");
function getTHE_FIRST_WORD()
{
return THE_FIRST_WORD;
}
$the_second_word = "Worl" . base64_encode(chr(100));
for ($the_h_counter = 0; $the_h_counter < 1; $the_h_counter++)
{
print $the_letter_h;
}
print getTHE_FIRST_WORD() . " " . substr($the_second_word, 0, 4) . base64_decode(substr($the_second_word, 4)). "!";
?>
</body>
</html>
Judas
Forum Commoner
Posts: 67 Joined: Tue Jun 10, 2003 3:34 pm
Location: Netherlands
Post
by Judas » Mon Jun 23, 2003 6:02 am
LOL
O boy i can be real complex!
cactus
Forum Regular
Posts: 343 Joined: Tue Jun 10, 2003 4:16 am
Location: UK
Post
by cactus » Mon Jun 23, 2003 6:19 am
Code: Select all
<?php
header('Content-type: text/html');
header("Cache-Control: "no-cache, must-revalidate"");
header("Pragma: "no-cache"");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
?>
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
$the_letter_h = "H";
define("THE_FIRST_WORD", "ello");
function getTHE_FIRST_WORD()
{
return THE_FIRST_WORD;
}
$the_second_word = bin2hex("W"). "orl" . base64_encode(chr(100));
for ($the_h_counter = 0; $the_h_counter < 1; $the_h_counter++)
{
print $the_letter_h;
}
print getTHE_FIRST_WORD() . " " . chr(hexdec(substr($the_second_word, 0, 2))) . substr($the_second_word, 2, 3) . base64_decode(substr($the_second_word, 5)). "!";
?>
</body>
</html>
Regards,
[edit: BTW, are we having a limit on the number additions per post ?]
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Mon Jun 23, 2003 10:41 am
cactus wrote: BTW, are we having a limit on the number additions per post ?
Nope, no limit at all.
EDIT:
Code: Select all
<?php
header('Content-type: text/html');
header("Cache-Control: "no-cache, must-revalidate"");
header("Pragma: "no-cache"");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
?>
<html><head><title>Complex Hello World</title></head>
<body>
<?php
// Help create the most complicated "Hello World" Application in the history of PHP!
$the_letter_h = "H";
$thefinalhoorah = "put the exclamation mark here";
define("THE_FIRST_WORD", "ello");
function getTHE_FIRST_WORD()
{
return THE_FIRST_WORD;
}
$the_second_word = bin2hex("W"). "orl" . base64_encode(chr(100));
for ($the_h_counter = 0; $the_h_counter < 1; $the_h_counter++)
{
print $the_letter_h;
}
print getTHE_FIRST_WORD() . " " . chr(hexdec(substr($the_second_word, 0, 2))) . substr($the_second_word, 2, 3) . base64_decode(substr($the_second_word, 5));
switch ($thefinalhoorah)
{
case "put the exclamation mark here":
echo "!";
break;
}
?>
</body>
</html>
A nice switch statement.
jason
Site Admin
Posts: 1767 Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:
Post
by jason » Mon Jun 23, 2003 1:06 pm
Code: Select all
<?php
header('Content-type: text/html');
header("Cache-Control: "no-cache, must-revalidate"");
header("Pragma: "no-cache"");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("X-PROGRAM-TYPE: HELO-WORLD");
class Person
{
var $_name;
var $_talking_to;
var $_listening_to;
function Person ( $name )
{
$this->setName($name);
}
function getName ()
{
return $this->_name;
}
function setName ( $name )
{
$this->_name = $name;
}
function talkTo ( &$person )
{
$this->_talking_to =& $person;
$this->_listening_to =& $person;
$this->_talking_to->listenTo($this);
$this->say("HELO ".$this->_talking_to->getName());
}
function say ( $string )
{
$this->_talking_to->hear($string);
}
function listenTo ( &$person )
{
$this->_listening_to =& $person;
}
function hear ( $string )
{
echo $string, "\n";
}
}
?>
<html><head><title>Complex Hello World</title></head><body>
<?php
$jason = new Person('Jason');
$world = new Person('World');
$jason->talkTo($world);
$world->talkTo($jason);
?>
</body></html>
Could have gone much further... but not yet.
HungryMind
Forum Commoner
Posts: 41 Joined: Fri Jun 20, 2003 10:33 am
Location: Alameda, CA
Post
by HungryMind » Mon Jun 23, 2003 1:14 pm
Very impressive code, but the output is:
HELO World HELO Jason
In order to get "Hello World!", wouldn't your code have to be:
Code: Select all
<?php
header('Content-type: text/html');
header("Cache-Control: "no-cache, must-revalidate"");
header("Pragma: "no-cache"");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("X-PROGRAM-TYPE: HELO-WORLD");
class Person
{
var $_name;
var $_talking_to;
var $_listening_to;
function Person ( $name )
{
$this->setName($name);
}
function getName ()
{
return $this->_name;
}
function setName ( $name )
{
$this->_name = $name;
}
function talkTo ( &$person )
{
$this->_talking_to =& $person;
$this->_listening_to =& $person;
$this->_talking_to->listenTo($this);
$this->say("Hello ".$this->_talking_to->getName());
}
function say ( $string )
{
$this->_talking_to->hear($string);
}
function listenTo ( &$person )
{
$this->_listening_to =& $person;
}
function hear ( $string )
{
echo $string, "\n";
}
}
?>
<html><head><title>Complex Hello World</title></head><body>
<?php
$jason = new Person('Jason');
$world = new Person('World!');
$jason->talkTo($world);
?>
</body></html>