function getUrlRoot($url){
Written by 小锋 on 09-11-13 1:58 PM
function getUrlRoot($url){
Written by 小锋 on 09-10-11 3:21 PM
SERVER端
<?php
//确保在连接客户端时不会超时
set_time_limit(0);
//设置IP和端口号
$address='127.0.0.1';
$port=2009; //调试的时候,可以多换端口来测试程序!
//创建一个SOCKET
if(($sock=socket_create(AF_INET,SOCK_STREAM,SOL_TCP))<0)
{
echo "socket_create() 失败的原因是:".socket_strerror($sock)."<br>";
}
//绑定到socket端口
if(($ret=socket_bind($sock,$address,$port))<0)
{
echo "socket_bind() 失败的原因是:".socket_strerror($ret)."<br>";
}
//开始监听
if(($ret=socket_listen($sock,4))<0)
{
echo "socket_listen() 失败的原因是:".socket_strerror($ret)."<br>";
}
do {
if (($msgsock = socket_accept($sock)) < 0)
{
echo "socket_accept() failed: reason: " . socket_strerror($msgsock) . "\n";
break;
}
//发到客户端
$msg ="<font color=red>欢迎进入服务器!</font><br>";
socket_write($msgsock, $msg, strlen($msg));
echo "读取客户端发来的信息<br>";
$buf = socket_read($msgsock,8192);
$talkback = "收到的信息:$buf<br>";
echo $talkback;
/* if(socket_write($msgsock, $talkback, strlen($talkback))<0)
{
echo "socket_write() failed: reason: " . socket_strerror($msgsock) . "\n";
}
else
{
echo "发送成功";
}*/
//echo $buf;
socket_close($msgsock);
} while (true);
socket_close($sock);
?>
CLIENT端
<?php
error_reporting(E_ALL);
set_time_limit(0);
echo "<h2>TCP/IP Connection</h2>\n";
$service_port = 2009;
$address = "127.0.0.1";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0)
{
echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
}
else
{
echo "OK.\n";
}
echo "试图连接 '$address' 端口 '$service_port'...<br>";
$result = socket_connect($socket, $address, $service_port);
if ($result < 0)
{
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
}
else
{
echo "连接OK<br>";
}
$in = "Hello\r\n";
$in .= "我是Chester\r\n";
$out = '';
$out1='';
if(!socket_write($socket, $in, strlen($in)))
{
echo "socket_write() failed: reason: " . socket_strerror($socket) . "\n";
}
else
{
echo "发送到服务器信息成功!<br>";
echo "发送的内容为:<font color='red'>$in</font> <br>";
}
while($out = socket_read($socket, 8192))
{
echo "接收服务器回传信息成功!<br>";
echo "接受的内容为:",$out;
}
echo "关闭SOCKET...<br>";
socket_close($socket);
echo "关闭OK<br>";
?>
先运行server.php
Written by 小锋 on 09-04-18 9:35 AM
想要eclipse 速度快那这个文章必看。。
» 阅读全文
Written by 小锋 on 09-04-14 12:35 AM
肥嘟嘟介绍的一篇关于排序问题的文章:)
» 阅读全文
Written by 小锋 on 09-02-27 3:03 AM
$n=round(1.95583, 2);
这是四舍五入法保留2位小数
Written by 小锋 on 09-02-22 3:22 AM
var_export($times,true);后面不加true不能写入文件哟
- $fp = fopen('aa.txt','w+');
- fwrite($fp,var_export($times,true));
- fclose($fp);
Written by 小锋 on 09-02-12 12:48 AM

设置x_axis_labels标签稍微有些复杂,之前介绍过x_axis对象有提供过set_labels_from_array方法,是创建对象方式标签,格式:
set_labels_from_array( $a ) //参数是一个数组定义
注意上面方法是x_axis对象的方法,别搞错!
OFC提供更进一步的设置x轴标签显示的参数,就是x_axis_labels
对象:x_axis_labels
方法:
事例代码:
效果演示:
点击查看PHP输出的格式
更为细节的设置x轴标签对象x_axis_label,注意和上面所说的x_axis_labels就一个s区别
对象:x_axis_label($text, $colour, $size, $rotate)
参数依次是标签名、标签颜色、标签大小、旋转方式("vertical" "diaganol" or "horizontal" )
方法:
事例代码:
转自http://www.51toria.cn/article.asp?id=137
Written by 小锋 on 09-02-12 12:46 AM

对象:y_axis
事例代码:
注意:y_axis默认位置是在左边,想设置在右边就要用与它有相同方法的另一个对象是y_axis_right,它们的方法一致!还有注意一些方法的重合性
效果演示:
正负y轴:
右边y轴:
点击查看PHP输出的格式
点击查看Y轴正负值格式
点击查看Y轴右边格式
转自http://www.51toria.cn/article.asp?id=134
Written by 小锋 on 09-02-06 1:48 AM
str_pad($i,2,'0',STR_PAD_LEFT)
Written by 小锋 on 09-02-02 12:59 AM
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>