Home  >  Article  >  Backend Development  >  Combined use of php with XML, XSLT, and Mysql, code_PHP tutorial

Combined use of php with XML, XSLT, and Mysql, code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:32:12758browse

(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

(standardization is getting closer)

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508714.htmlTechArticle?php (as the current mainstream development language) require_once "DB.php (as the current mainstream development language) ) "; //Database processing class in PEAR dataType = "MySQL (the best combination with PHP)...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn