<?php
$getConnectionCountsPage = file_get_contents('http://10.57.180.171/getconnectioncounts');
$xml=simplexml_load_string($getConnectionCountsPage) or die("Error: Cannot create object");
foreach ($xml->VHost->ConnectionsCurrent as $child)
{
echo $child;
}
?>
痞客興 發表在 痞客邦 留言(0) 人氣(179)
在你使用PHP去連MSSQL做資料的存取時,會遇到亂碼的問題
這是因為MSSQL和PHP使用了不同的編碼所導致
痞客興 發表在 痞客邦 留言(0) 人氣(427)

在實現以下的方法之前,你必須要在PHP上面安裝MSSQL driver
安裝的作法可以參考這篇 http://charleslin74.pixnet.net/blog/post/448010417-[php]-php%E5%AE%89%E8%A3%9Dmssql-driver%E7%9A%84%E6%96%B9%E6%B3%95
痞客興 發表在 痞客邦 留言(0) 人氣(4,955)

1. 首先你必須確認你的PHP版本,你應該不陌生下面這段code
<?php
phpinfo();
?>
痞客興 發表在 痞客邦 留言(0) 人氣(1,093)
開檔並讀取檔案內容的範例
$filename = "yourfile.txt";
$tmpstr = "";
if(file_exists($filename)){
$file = fopen($filename, "r");
if($file != NULL)
{
while (!feof($file)) {
$str .= fgets($file);
}
fclose($file);
}
}
echo $tmpstr;
痞客興 發表在 痞客邦 留言(0) 人氣(2,562)
str_replace(array("\r", "\n", "\r\n", "\n\r"), '', $str);
$str就是你的原來字串,利用str_replace將所有可能的換行符號網且放到陣列裡,只要符合其中一組,就會換成'',這樣就清掉了.
痞客興 發表在 痞客邦 留言(0) 人氣(7,913)
這個程式是使用PHP來讀取寫入文字檔,及刪除文字檔某一行,類以文字檔做簡易資料庫的方法
程式碼如下
痞客興 發表在 痞客邦 留言(0) 人氣(428)
本範例取自http://stackoverflow.com/questions/4356289/php-random-string-generator
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
痞客興 發表在 痞客邦 留言(0) 人氣(419)