PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 13. (Msn web hosting)
PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY 13. What happens, though, if you have page names that don t make good titles? The home page of the Japan Journey site is called index.php. As the following screen- shot shows, applying the current solution to this page doesn t seem quite right. There are two solutions: either don t apply this technique to such pages or use a conditional statement (an if statement) to handle special cases. For instance, to display Home instead of Index, amend the code in title.inc.php like this: The first line of the conditional statement uses two equal signs to check the value of $title. The following line uses a single equal sign to assign the new value to $title. If the page is called anything other than index.php, the line inside the curly braces is ignored, and $title keeps its original value. PHP is case-sensitive, so this solution works only if index is all lowercase. To do a case-insensitive comparison, change the fourth line of the preceding code like this: if (strtolower($title) == ‘index’) { The function strtolower() converts a string to lowercase hence its name and is frequently used to make case-insensitive comparisons. The conversion to lowercase is not permanent, because strtolower($title) isn t assigned to a variable; it s only used to make the comparison. To make a change permanent, you need to assign the result back to a variable as in the final line, when ucwords($title) is assigned back to $title. To convert a string to uppercase, use strtoupper(). 14. Save title.inc.php and reload index.php into a browser. The page title now looks more natural, as shown in the following screenshot.
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.