- PHP code works on Web pages by embedding itself within HTML code. While HTML tags can be inserted anywhere on a page, PHP code has to be surrounded with the tags "<?php" at the beginning of the PHP code segment and "?>" at the end. Web designers can replace the normal static settings for HTML, such as buttons or link addresses, with PHP code, which can supply those values.
- Without supplemental PHP code, a Web designer has to set the appearance of the HTML button statically when he codes the Web page. This can be the default HTML button image, or a graphic the designer supplies. With PHP, the designer can slip a PHP code segment into the area where he normally would put the name of the button graphic; this code pulls a graphic from a database slot. The designer can make a separate client that can change the graphic this database slot holds, thus automatically changing the button graphic without having to touch the page's source code.
- Another trick to play with a button's appearance in PHP is to use PHP's random function to randomize what appearance a button will take when the end user loads a Web page. The user can do this with a series of "if" statements that are each linked to a different file name for a different graphic. This script runs each time the page loads to display a random graphic from a set of graphics.
- Web page designers also can use PHP's random function to change the function a button on a Web page performs. This could take the form of making a button point to a URL that a PHP script randomly selects from a list. To do this, a Web designer slips the randomizing PHP code into the link value of a button's HTML code rather than its display parameter. The "if" statements then echo different link values rather than the names of graphical files.
PHP Embedding
Remotely Manage Button Image
Random Button Graphic
Random Link Path
SHARE