This essay has been submitted by a student. This is not an example of the work written by professional essay writers.
Country

Country Code Converter

Pssst… we can write an original essay just for you.

Any subject. Any type of essay. We’ll even meet a 3-hour deadline.

GET YOUR PRICE

writers online

Country Code Converter

In this program, PHP language has been used to convert user input, that is, country name, to IOC (International Olympic Committee) country codes. Hypertext Processor (PHP), is suitable here mainly because of how it can handle a wide range of databases.[1]

 

Here, the PHP opening tag, <?php , has to be called to ensure the proper functioning of program values. From here, an array list has to be created, in which it contains all the IOC member countries and their country codes.

The parameter value given to my array is (countryarray). An array is simply a particular variable which can hold more than one value at a time.[2] For this specific program, the set of data combines to make an associative array, where the string indexes values are assigned particular keys. For example;

The country Bulgaria has been assigned the key ‘BUL’, the country Canada has been assigned the key ‘CAN’ , etc. In its indexing, no two countries in IOC country codes share one key.

Don't use plagiarised sources.Get your custom essay just from $11/page

After creating the array list, a function that allows the parameters of the user input to be called is then included; that is;

function countryselector($defaultCountry = “” , $name = “” , $code = “”){

Where, the user input parameters are, name(Country name) and code(Country Code).

The function to select the values after the user input is then added. That is;

$output = “<select  name='”.$name.”‘ codes='”.$code.”‘>”;

foreach($countryArray as $code => $country){

$countryName = ucwords(strtolower($country[“name”]));

$output .= “<option value='”.$code.”‘ “.(($code==strtoupper($defaultCountry))?”selected”:””).”>”.$code.” – “.$countryName.” (+”.$country[“code”].”)</option>”;

}

 

$output .= “</select>”;

 

The final code lines allow the program, after user input, to select from the array, any given country which automatically displays the code.

In the last code line, the end tag ?>  should be included to indicate the end of the program.

 

Thus, in the results, once the user enters a country name, the program is commanded to generate code, then the country code will be displayed as output.

In any case, a country that does not belong to the International Olympic Committee is entered by the user; an exception has to be thrown to indicated wrong input of data by the user.

if (null === $country) {

die(‘Country not found!’);

}

 

Here, the function, if, is used to prompt the program to note an error, if any, from the user. The keyword null shows that the data input is unavailable in the array list, thus sends out an error message of ‘Country not found’, as the output.

For the optimized efficiency of the program, MySQL may be used in place of the array list created. MySQL guarantees such issues as data security, high performance of the database administration, and flexibility of open source. In addition to that, MySQL allows easier and accurate entry of data, better-looking output since such features as tables can be used and complete workflow control.[3]

For better performance of the program in terms of speed, the number of users in the web application and the capacity of the servers to handle requests and responses to specific requests should be monitored. Third-party applications and software can be used in an event the requests applications lag.

Correspondingly, caching in on the programs can help in reducing the database load and saving execution time when scripts get compiled, hence enhancing the speed and saving time.

 

 

 

 

 

 

Reference List

PHP Introduction. https://www.w3schools.com/php/php_intro.asp

PHP;  Arrays. https://www.geeksforgeeks.org/php-arrays/.

Branson, T(2016, November 16).8 Advantages of Using MySQL.https://www.datamation.com/storage/8-major-advantages-of-using-mysql.html

  Remember! This is just a sample.

Save time and get your custom paper from our expert writers

 Get started in just 3 minutes
 Sit back relax and leave the writing to us
 Sources and citations are provided
 100% Plagiarism free
error: Content is protected !!
×
Hi, my name is Jenn 👋

In case you can’t find a sample example, our professional writers are ready to help you with writing your own paper. All you need to do is fill out a short form and submit an order

Check Out the Form
Need Help?
Dont be shy to ask