# Just for fun...

**URL:** <https://www.phphelp.com/t/just-for-fun/23805>\
**Category:** General Chat\
**Created:** [December 19, 2014, 2:56am UTC](https://www.phphelp.com/t/just-for-fun/23805 "2014-12-19T02:56:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 2:56am UTC](https://www.phphelp.com/t/just-for-fun/23805/1 "2014-12-19T02:56:07Z")

</div>

In PHP there are many ways to do the same thing. (Perhaps not such a good idea…). For fun, I would like to see how many ways we can come up with to output the basic Hello World phrase. I am guessing we could come up with at least a hundred. I will start with the two most obvious ones and contribute more when the list gets going.

1.[php]\<?php  
echo “Hello World”;  
?\>[/php]

2.[php]\<?php  
print “Hello World”;  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 4:14pm UTC](https://www.phphelp.com/t/just-for-fun/23805/2 "2014-12-19T16:14:50Z")

</div>

[php]\<?php

$hex = ‘48 65 6c 6c 6f 20 57 6f 72 6c 64’;  
foreach (explode(’ ', $hex) as $bit) {  
echo chr(hexdec($bit));  
}[/php]

---

<div class="post-metadata">

**Author:** ![Topcoder](https://www.phphelp.com/user_avatar/www.phphelp.com/topcoder/32/4356_2.png) [@Topcoder](https://www.phphelp.com/u/Topcoder)\
**Post date:** [December 19, 2014, 5:20pm UTC](https://www.phphelp.com/t/just-for-fun/23805/3 "2014-12-19T17:20:37Z")

</div>

[php]\<?php  
$test = “Hello World”;  
var\_export($test);  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 5:56pm UTC](https://www.phphelp.com/t/just-for-fun/23805/4 "2014-12-19T17:56:40Z")

</div>

[php]\<?php  
echo base64\_decode(‘SGVsbG8gV29ybGQ=’);  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 6:19pm UTC](https://www.phphelp.com/t/just-for-fun/23805/5 "2014-12-19T18:19:01Z")

</div>

[php]echo hex2bin(“48656c6c6f20776f726c6421”);[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 6:48pm UTC](https://www.phphelp.com/t/just-for-fun/23805/6 "2014-12-19T18:48:29Z")

</div>

[php]\<?php  
foreach (range(‘d’, ‘w’) as $v) {  
$a[] = $v;  
}  
echo ucwords("$a[4]$a[1]$a[8]$a[8]$a[11] $a[19]$a[11]$a[14]$a[8]$a[0]!");  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 6:49pm UTC](https://www.phphelp.com/t/just-for-fun/23805/7 "2014-12-19T18:49:20Z")

</div>

[php]\<?php  
echo \<\<\<EOD  
Hello World  
EOD;[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 6:51pm UTC](https://www.phphelp.com/t/just-for-fun/23805/8 "2014-12-19T18:51:01Z")

</div>

the obvious one…

[php]\<?php  
?\>  
Hello World[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 6:52pm UTC](https://www.phphelp.com/t/just-for-fun/23805/9 "2014-12-19T18:52:48Z")

</div>

[php]\<?php  
foreach (range(‘d’, ‘w’) as $v) {  
$a[] = $v;  
}  
echo ucwords("$a[4]$a[1]$a[8]$a[8]$a[11] $a[19]$a[11]$a[14]$a[8]$a[0]!");  
[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 6:57pm UTC](https://www.phphelp.com/t/just-for-fun/23805/10 "2014-12-19T18:57:03Z")

</div>

> [@JimL](#):
>
> [php]\<?php  
> foreach (range(‘d’, ‘w’) as $v) {  
> $a = $v;  
> }  
> echo ucwords(“$a[4]$a[1]$a[8]$a[8]$a[11] $a[19]$a[11]$a[14]$a[8]$a[0]!”);  
> [/php]

[member=71845]JimL[/member] , I messed it up when I pasted in the ucwords update.

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 6:58pm UTC](https://www.phphelp.com/t/just-for-fun/23805/11 "2014-12-19T18:58:47Z")

</div>

[php]\<?php  
foreach (explode(’ ', ‘72 101 108 108 111 32 87 111 114 108 100’) as $bit) {  
echo chr($bit);  
}[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 7:00pm UTC](https://www.phphelp.com/t/just-for-fun/23805/12 "2014-12-19T19:00:29Z")

</div>

[member=46186]Kevin Rubio[/member] still, the loop is unnecessary

[php]\<?php  
$a = range(‘d’, ‘w’);  
echo ucwords("$a[4]$a[1]$a[8]$a[8]$a[11] $a[19]$a[11]$a[14]$a[8]$a[0]!");[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 7:11pm UTC](https://www.phphelp.com/t/just-for-fun/23805/13 "2014-12-19T19:11:36Z")

</div>

> [@JimL](#):
>
> [member=46186]Kevin Rubio[/member] still, the loop is unnecessary
> 
> [php]\<?php  
> $a = range(‘d’, ‘w’);  
> echo ucwords(“$a[4]$a[1]$a[8]$a[8]$a[11] $a[19]$a[11]$a[14]$a[8]$a[0]!”);[/php]

[member=71845]JimL[/member] , Good one, yet still another way to do it.

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 19, 2014, 7:12pm UTC](https://www.phphelp.com/t/just-for-fun/23805/14 "2014-12-19T19:12:42Z")

</div>

[php]\<?php  
$b=(‘010010000110010101101100011011000110111100100000010101110110111101110010011011000110010000100001’);  
$split = str\_split($b, 8);  
$txt = ‘’;  
for($i = 0, $l = count($split); $i \< $l; $i++) {  
$txt .= chr(bindec($split[$i]));  
}  
echo $txt;  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![JimL](https://www.phphelp.com/user_avatar/www.phphelp.com/jiml/32/1842_2.png) [@JimL](https://www.phphelp.com/u/JimL)\
**Post date:** [December 19, 2014, 11:31pm UTC](https://www.phphelp.com/t/just-for-fun/23805/15 "2014-12-19T23:31:45Z")

</div>

[php]\<?php  
$_="\x70\162\151\x6e\164\x5f\162";$ **="\145\170\x65\x63";$** _="\x65\143\150\x6f";$**_="\110\x65\154\x6c\x6f\040\127\x6f\x72\x6c\144\047";  
$($("$_ '$**\_\_"));[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 20, 2014, 12:23am UTC](https://www.phphelp.com/t/just-for-fun/23805/16 "2014-12-20T00:23:13Z")

</div>

[php]\<?php  
echo str\_replace(“JimL”,“World”,“Hello JimL!”);  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 20, 2014, 12:27am UTC](https://www.phphelp.com/t/just-for-fun/23805/17 "2014-12-20T00:27:55Z")

</div>

[php]\<?php  
echo strrev("!dlroW olleH");  
?\>[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 20, 2014, 12:39am UTC](https://www.phphelp.com/t/just-for-fun/23805/18 "2014-12-20T00:39:34Z")

</div>

[php]echo str\_rot13(“Uryyb Jbeyq!”);[/php]

---

<div class="post-metadata">

**Author:** ![benanamen](https://www.phphelp.com/user_avatar/www.phphelp.com/benanamen/32/287_2.png) [@benanamen](https://www.phphelp.com/u/benanamen)\
**Post date:** [December 20, 2014, 1:18am UTC](https://www.phphelp.com/t/just-for-fun/23805/19 "2014-12-20T01:18:17Z")

</div>

[php]echo strtr(“Happy Coder!”,“apyCder”,“eloWrld”);[/php]

---

<div class="post-metadata">

**Author:** ![Redscouse](https://www.phphelp.com/user_avatar/www.phphelp.com/redscouse/32/124_2.png) [@Redscouse](https://www.phphelp.com/u/Redscouse)\
**Post date:** [December 20, 2014, 9:19pm UTC](https://www.phphelp.com/t/just-for-fun/23805/20 "2014-12-20T21:19:31Z")

</div>

[php]  
define(“CONSTANT”, “Hello world.”);  
echo CONSTANT;  
[/php]

;D

[Next page](https://www.phphelp.com/t/just-for-fun/23805.md?page=2)
