home forums resources search newsjoinmembers: 6954
Sections PHP Flash Java Ruby Windows Linux
Carl's picture

Carl | Sun, 2008-08-24 05:43  tags: , , , ,

I fell asleep while reading the Java Server Programming J2EE Edition again. But this time when I awoke I sat down and wrote some PHP code that is total gibberish, does not produce any errors and seems to be written in beer language.

<?php

class Foo
{
  private 
$_stock null;
  private 
$_keg null;
    function 
__construct($name,$arg4)
    {
        
$this->$name(' today');
                
$arg1 ' has ale';
                
$arg2 ' and pale ale';
                
$arg3 ' and light beer';
                
$this->$name($arg1,$arg2);
                
$this->$name($arg1,$arg2,$arg3,$arg4);
    }
        function 
Variable()
    {
      
$string implode(func_get_args());
            
$this->Bar($string); // This calls the Bar() method
    
}
    function 
Bar($string)
    {
        echo 
"This is Bar" $string .'<br>';
    }
}
$funcname "Variable";
$foo = new Foo($funcname' tomorrow');
$foo->Bar(' is open');
$foo->$funcname(' has moved');

?>

I have no idea what problem I was trying to solve while asleep but it might be that I was just thirsty?


Happy Publishing!

Carl's picture
Ten years of experience in web development. Carl is looking for in employment as a Senior PHP/mySQL Developer in Stockholm.
Carl McDade - Systems Developer
Thoughtbox - So what did you think?



Carl posted on: Sun, 2008-08-24 09:00.

After a couple of hours sleep and a glass of water the code gets to be a bit more clear. At least it is useful in this state. Though I have not yet come upon when it is useful.

<?php

class Foo{
  private 
$_stock null;
  private 
$_keg null;
    function 
__construct($name,$arg4){
        
$arg0 ' is closed today';
                
$arg1 ' has ale';
                
$arg2 ' and pale ale';
                
$arg3 ' and light beer';
                switch (
$name){
                case 
'cheers':
                     
$this->check_access(' is open today');
                     
$this->$name($arg1,$arg2,$arg4);
                    break;
                case 
'warsaw_tavern':
                     
$this->check_access(' has no beer today');
                     
$this->$name($arg1,$arg2,$arg3,$arg4);
                    break;
                default:
                    
$this->$name($arg0);
                    break;
                }
    }
        function 
check_access(){
      
$string implode(func_get_args());
            
$this->Bar($string); // This calls the Bar() method
    
}
        function 
cheers(){
      
$string implode(func_get_args());
            
$this->Bar($string); // This calls the Bar() method
    
}
        function 
warsaw_tavern(){
      
$string implode(func_get_args());
            
$this->Bar($string); // This calls the Bar() method
    
}
    function 
Bar($string){
        echo 
"This Bar" $string .'<br>';
    }
}
$funcname "check_access";
$foo = new Foo($funcname' is open tomorrow');
$foo->$funcname(' has moved');
$foo->Bar(' is open');
$funcname "cheers";
$foo = new Foo($funcname' tomorrow at cheers');
$funcname "warsaw_tavern";
$foo = new Foo($funcname' tomorrow at WT\'s');

?>

the output

This Bar is closed today
This Bar has moved
This Bar is open
This Bar is open today
This Bar has ale and pale ale tomorrow at cheers
This Bar has no beer today
This Bar has ale and pale ale and light beer tomorrow at WT's

 
CMS Comparison Matrix
 
Content Management Systems Adobe Flex Joomla! Silverlight Wordpress Drupal Content Management Systems

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.