Skip to content

Instantly share code, notes, and snippets.

@surajitbasak109
Created February 9, 2018 04:08
Show Gist options
  • Save surajitbasak109/9fc085c5bf6c7962efd598c410c1cccb to your computer and use it in GitHub Desktop.
Save surajitbasak109/9fc085c5bf6c7962efd598c410c1cccb to your computer and use it in GitHub Desktop.
<?php # Script 4.1 - HelloWorld.php
/* This page defines the HelloWorld class.
* The class says "Hello World!" in different languages.
*/
class HelloWorld
{
// This method print a greeting
// It takes one argument: the language to use.
// Default language is English.
function sayHello( $language = "English" )
{
// Put the greeting within P tags:
echo '<p>';
// print a message specific to language
switch( $language )
{
case 'Hindi':
echo 'नमस्ते दुनिया';
break;
case 'Greek':
echo 'Γειά σου Κόσμε';
break;
case 'Chinese Simplified':
echo '你好,世界';
break;
case 'Chinese Traditinal':
echo '你好,世界';
break;
case 'Japanese':
echo 'こんにちは世界';
break;
case 'Bengali':
echo 'ওহে বিশ্ব!';
break;
case 'Dutch':
echo 'Hallo, Wereld!';
break;
case 'French':
echo 'Bonjour, Monde!';
break;
case 'German':
echo 'Hallo, Welt!';
break;
case 'Italian':
echo 'Ciao, Mondo!';
break;
case 'Spanish':
echo 'iHola, Mundo!';
break;
default:
echo 'Hello World!';
break;
} // end of switch
// close the HTML paragrath tag
echo '</p>';
} // End of sayHello() method
} // End of HelloWorld class
$language = ! empty ( $_GET['lang'] ) ? $_GET['lang'] : 'English';
$helloworld = new HelloWorld();
$helloworld->sayHello( $language );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment