406PHP5/MySQLProgrammingfortheAbsoluteBeginner$values[] = $value; } // end if} //
October 27, 2006 on 5:18 am | In php | No CommentsWhen you include a file, it is interpreted as HTML, not PHP. This means you canplace any HTML code in an includefile and it is automatically inserted in youroutput wherever the includefunction occurred. I took advantage of this fact toinclude a CSS block in the library. If you want PHP code in your library file, surround your code with PHP tags ( ?>) in the library file. Setting Systemwide VariablesAnother huge advantage of a library file is the ability to set and use variables thathave meaning throughout the entire system. Since each PHP program in the sys- tem includes the library, all have access to any variables declared in the libraryfile s main section. Of course, you need to use the globalkeyword to access aglobal variable from within a function. //spyLib.php//holds utilities for spy database//variables$userName = ?; $password = ?; $serverName = localhost ?; $dbName = chapter12 ?; $dbConn = ?; $adminPassword = absolute ?; $mainProgram = spyMaster.php ?; I stored a few key data points in the systemwide variables. The $userName, $password, and $serverNamevariables set up the data connection. I did this because I expectpeople to reuse my library for their own databases. They definitely need tochange this information to connect to their own copy of MySQL. It s much saferfor them to change this data in variables than in actual program code. If you rewriting code for reuse, consider moving anything the code adopter might changeinto variables. The $adminPasswordvariable holds the password used to edit data in the system. Again, I want anybody reusing this library (including me) to change this valuewithout having to dig through the code. The $mainProgramvariable holds the URL of the control pad ? program of the sys- tem. In the spysystem, I want to provide access to spyMaster.phpin every screen. HINT407Chapter
Hint: If you are looking for very good and affordable webspace to host and run your java hosting application check Virtualwebstudio java web hosting provider
406PHP5/MySQLProgrammingfortheAbsoluteBeginner$values[] = $value; } // end if} //
October 27, 2006 on 5:18 am | In php | No Comments406PHP5/MySQLProgrammingfortheAbsoluteBeginner$values[] = $value; } // end if} // end foreachprint procAdd($theTable, $fields, $values); print mainButton(); ?>