Home >Backend Development >PHP Tutorial >Combined use of php with XML, XSLT, and Mysql, code_PHP tutorial
(as the current mainstream development language)
require_once "DB.php(as the current mainstream development language)"; //PEAR Database processing class in
$dataType = "MySQL(The best combination with PHP)" ; //Database type
$user = "root"; > $pass = "abcd" ; //Password
$host="202.96.215.200"; //MySQL
(The best combination with PHP)Database server address $db_name = "test"; //Database name
$dsn="$dataType://$user:$pass@$host/$db_name"; //DNS configuration to connect to the database
$db = DB::connect ($dsn); //Connect to the database
if (DB::isError($db))
{ {
}
//The following two are public functions
/**
* Read xsl document
*
* @param String $filename - the name of the xsl file
* @return string
*/
function readXsl($filename)
{
if(false= = File_exists ($ FILENAME))
{
Echo "The file & lt; font color = red & gt; $ firename & lt;/font & gt; n false ;
}
return implode(, file($filename));
} //end function readXsl
/**
* Convert xml
file or array variable into HTML content based on xsl file
* http://www.acnow.net/* @ param array $arydata - array variable* @param String $xslstring - xsl document data
* @param String $xml
(Standardization is getting closer)
string - xml
( Standardization is getting closer)Document data*/function getHtml($arydata = false, $xslstring = false, $xml(Standardization is getting closer)
string = false)
{ global $db; //Use the $db object just now include_once("xml
(Standardization is getting closer)
/sql2xml
(Standardization is getting closer).php(as the current mainstream development language)"); //Include sql2xml(Standardization is getting closer) $sql2xml(Standardization is getting closer)class = new xml
(Standardization is getting closer)_sql2xml(Standardization is getting closer)($db); //Example of sql2xml(Standardization is getting closer) $sql2xml(Standardization is getting closer)class->setEncoding("GB2312"); //Set the transcoding type of data
if (false == $xml(Standardization is getting closer)string) { // If the user passes in array data, apply the array data to )
Node name of document data