仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1613|回复: 19
打印 上一主题 下一主题

[学习教程] PHP教程之PHP中文函数连载(二)

[复制链接]
若天明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:54:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
我假设你目前已经可以完成一个静态页面了,当然,做的好看难看是另外一说,皮皮我的第一个网页也没好看到哪去,但是“孩子”再丑,咱们做“爹妈”的也不能嫌弃不是?这毕竟是咱的成果。函数|中文   函数count()
描写:
盘算一变量中元素的个数
int count (mixed var);
Returns the number of elements in var , which is typically an array (since anything else will have one element).
Returns 0 if the variable is not set.
Returns 1 if the variable is not an array.

函数current()
描写:
传回数组指针今朝所指的元素

mixed current (array array);

Each array variable has an internal pointer that points to one of its elements. In addition, all of the elements in the array are linked by a bidirectional linked list for traversing purposes. The internal pointer points to the first element that was inserted to the array until you run one of the functions that modify that pointer on that array.

The current()</B> function simply returns the array element that's currently being pointed by the internal pointer. It does not move the pointer in any way. If the internal pointer points beyond the end of the elements list, current()</B> returns false.

函数each()
描写:
前往数组中下一对key/value的值

array each (array array);

Returns the current key/value pair from the array array and advances the array cursor. This pair is returned in a four-element array, with the keys 0 , 1 , key , and value . Elements 0 and key each contain the key name of the array element, and 1 and value contain the data.

Example 1. each()</B> examples

$foo = array( "bob", "fred", "jussi", "jouni" ); $bar = each( $foo );
$bar now contains the following key/value pairs:

0 => 0
1 => 'bob'
key => 0
value => 'bob'

$foo = array( "Robert" => "Bob", "Seppo" => "Sepi" ); $bar = each( $foo );

$bar now contains the following key/value pairs:

0 => 'Robert'
1 => 'Bob'
key => 'Robert'
value => 'Bob'

Example 2. Traversing $HTTP_POST_VARS with each()</B>

echo "Values submitted via POST method:<br>";
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
echo "$key => $val<br>";
}

函数end()
描写:
将数组中的指针移到最初一个
end (array array);
end()</B> advances array 's internal pointer to the last element.

函数key()
描写:
从一数组中掏出key
mixed key (array array);
key()</B> returns the index element of the current array position.

函数ksort()
描写:
以key来分列一数组
Example 1. ksort()</B> example

$fruits = array("d"=>"lemon","a"=>"orange","b"=>"banana","c"=>"apple");
ksort($fruits);
for(reset($fruits);
$key = key($fruits);
next($fruits)) { echo "fruits[$key] = ".$fruits[$key]."\n"; }

This example would display: fruits[a] = orange fruits = banana fruits[c] = apple fruits[d] = lemon

函数list()
描写:
用相似数组的体例去指定一整串变量的值
Example 1. list()</B> example

<table> <tr> <th> Employee name</th>
<th>Salary</th> </tr>
<?php $result = mysql($conn, "SELECT id, name, salary FROM employees");
while (list($id, $name, $salary) = mysql_fetch_row($result)) {
print(" <tr>\n"."<td><a href=\"info.php3?id=$id\">$name</a></td>\n"."<td>$salary</td>\n"." </tr>\n");
}
?>
</table>

函数next()
描写:
将数组的指向指到下一组数据


函数pos()
描写:
传回数组确当前的数据

函数prev()
描写:
传回数组的前一条的数据

函数reset()
描写:
数组的指针指到第一条

函数rsort ()
描写:
以倒序体例分列一个数组
Example 1. rsort()</B> example

$fruits = array("lemon","orange","banana","apple");
rsort($fruits);
for(reset($fruits); ($key,$value) = each($fruits); ) {
echo "fruits[$key] = ".$value."\n";
}

This example would display: fruits[0] = orange fruits[1] = lemon fruits[2] = banana fruits[3] = apple The fruits have been sorted in reverse alphabetical order.

函数sizeof()
描写:
获得一个数组的巨细和元素的数量

函数sort()
描写:
排序数组
Example 1. sort()</B> example

$fruits = array("lemon","orange","banana","apple");
sort($fruits);
for(reset($fruits);
$key = key($fruits);
next($fruits)) {
echo "fruits[$key] = ".$fruits[$key]."\n";
}

This example would display: fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange The fruits have been sorted in alphabetical order.

函数uasort()
描写:
以自界说的体例分列一个数组且序列不变。


函数uksort()
描写:
以自界说的体例以key分列
This function will sort the keys of an array using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. Example 1. uksort()</B> example

function mycompare($a, $b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
$a = array(4 => "four", 3 => "three", 20 => "twenty", 10 => "ten");
uksort($a, mycompare);
while(list($key, $value) = each($a)) {
echo "$key: $value\n";
}


This example would display: 20: twenty 10: ten 4: four 3: three

函数usort()
描写:
以自界说的体例以value分列

void usort (array array, function cmp_function);

This function will sort an array by its values using a user-supplied comparison function. If the array you wish to sort needs to be sorted by some non-trivial criteria, you should use this function. Example 1. usort()</B> example

function cmp($a,$b) {
if ($a == $b) return 0;
return ($a > $b) ? -1 : 1;
}
$a = array(3,2,5,6,1);
usort($a, cmp);
while(list($key,$value) = each($a)) {
echo "$key: $value\n";
}


This example would display: 0: 6 1: 5 2: 3 3: 2 4: 1 Obviously in this trivial case the rsort()</B> function would be more appropriate.
BC (Arbitrary Precision) Functions


函数bcadd()
描写:
Add two arbitrary precision numbers
string bcadd (string left operand, string right operand, int [ scale ]); 左面的字符加左面的字符,前往一个字符。


函数bccomp()
描写:
int bccomp (string left operand, string right operand, int [ scale ]);
左面的字符和左面的字符停止对照,假如相等的话前往0,假如左面的比左面的长前往+1,左面的比左面的长前往-1


函数bcdiv()
描写:
Divide two arbitrary precision numbers
string bcdiv (string left operand, string right operand, int [ scale ]); 将左面的字符串以左面的字符串为尺度分隔


函数bcmod()
描写:
Get modulus of an arbitrary precision number
string bcmod (string left operand, string modulus);
用左面的modulus操作左面的字符串


函数bcmul()
描写:
Multiply two arbitrary precision number
string bcmul (string left operand, string right operand, int [ scale ]);
Multiply the left operand by the right operand and returns the result. The optional scale sets the number of digits
after the decimal place in the result.


函数bcpow()
描写:
Raise an arbitrary precision number to another.
Raise x to the power y . The scale can be used to set the number of digits after the decimal place in the result.


函数bcscale()
描写:
Set default scale parameter for all bc math functions.
string bcscale (int scale);
This function sets the default scale parameter for all subsequent bc math functions that do not explicitly specify a scale
parameter


函数bcsqrt()
描写;
string bcsqrt (string operand, int scale);
前往字符的平方根


函数bcsub()
描写:
string bcsub (string left operand, string right operand, int [ scale ]);
将左面的字符减去左面的字符


Calendar Functions日历功效


函数JDToGregorian()
描写:
string jdtogregorian (int julianday);
将Julian日历转换成Gregorian日历


函数GregorianToJD()
描写:
int gregoriantojd (int month, int day, int year);
将Gregorian日历转换成Julian日历


函数JDToJulian ()
描写:
string jdtojulian (int julianday);
将Julian Calendar转换Julian Day


函数JulianToJD ()
描写:
int juliantojd (int month, int day, int year);


函数JDToJewish ()
描写:
Converts a Julian Day Count to the Jewish Calendar
string jdtojewish (int julianday);


函数JewishToJD()
描写:
Converts a date in the Jewish Calendar to Julian Day Count
int jewishtojd (int month, int day, int year);


函数JDToFrench()
描写:
Converts a Julian Day Count to the French Republican Calendar
string jdtofrench (int month, int day, int year);


函数FrenchToJD()
描写:
Converts a date from the French Republican Calendar to a Julian Day Count int frenchtojd (int month, int day, int year);


函数JDMonthName ()
描写:
Returns a month name
string jdmonthname (int julianday, int mode);
Mode Meaning
0 Gregorian - apreviated
1 Gregorian
2 Julian - apreviated
3 Julian
4 Jewish
5 French Republican


函数JDDayOfWeek ()
描写:
Returns the day of the week
mixed jddayofweek (int julianday, int mode);
Mode Meaning
0 returns the day number as an int (0=sunday, 1=monday, etc)
1 returns string containing the day of week (english-gregorian)
2 returns a string containing the abreviated day of week (english-gregorian)
不过还好,PHP语言给出的语法错误很详细,只要稍微熟悉一点之后,看错误提示就能很容易找出错误所在的。PHP还有一个特别好用的调试功能,在PHP语句中,你可以随时用echo来输出结果。
小女巫 该用户已被删除
沙发
发表于 2015-2-4 06:58:39 | 只看该作者
在我安装pear包的时候老是提示,缺少某某文件,才发现 那群extension 的排列是应该有一点的顺序,而我安装的版本的排序不是正常的排序。没办法我只好把那群冒号加了上去,只留下我需要使用的扩展。
简单生活 该用户已被删除
板凳
发表于 2015-2-9 18:15:52 | 只看该作者
兴趣是最好的老师,百度是最好的词典。
再见西城 该用户已被删除
地板
发表于 2015-2-10 05:40:11 | 只看该作者
开发工具也会慢慢的更专业,每个公司的可能不一样,但是zend studio是个大伙都会用的。
若相依 该用户已被删除
5#
发表于 2015-2-20 13:14:40 | 只看该作者
基础有没有对学习php没有太大区别,关键是兴趣。
小妖女 该用户已被删除
6#
发表于 2015-3-6 17:08:53 | 只看该作者
php里的数组为空的时候是不能拿来遍历的;(这个有点低级啊,不过我刚被这个边界问题墨迹了好长一会)
再现理想 该用户已被删除
7#
发表于 2015-3-13 04:29:21 | 只看该作者
找到的的资料很多都是在论坛里的,需要注册,所以我一般没到一个论坛都注册一个id,所有的id都注册成一样的,这样下次再进来的时候就不用重复注册啦。当然有些论坛的某些资料是需要的付费的。
精灵巫婆 该用户已被删除
8#
发表于 2015-3-15 04:27:11 | 只看该作者
至于模板嘛,各位高人一直以来就是争论不休,我一只小菜鸟就不加入战团啦,咱们新手还是多学点东西的好。
金色的骷髅 该用户已被删除
9#
发表于 2015-3-17 16:09:32 | 只看该作者
先学习php和mysql,还有css(html语言很简单)我认为现在的效果比以前的方法好。
若天明 该用户已被删除
10#
 楼主| 发表于 2015-3-24 11:03:51 | 只看该作者
首先我是坚决反对新手上来就用框架的,因为对底层的东西一点都不了解,造成知识上的真空,会对以后的发展不利。我的观点上手了解下框架就好,代码还是手写。当然啦如果是位别的编程语言的高手的话,这个就另当别论啦。
海妖 该用户已被删除
11#
发表于 2015-4-1 03:11:01 | 只看该作者
首推的搜索引擎当然是Google大神,其次我比较喜欢 百度知道。不过搜出来的结果往往都是 大家copy来copy去的,运气的的概率很大。
因胸联盟 该用户已被删除
12#
发表于 2015-4-4 04:37:10 | 只看该作者
建数据库表的时候,int型要输入长度的,其实是个摆设的输入几位都没影响的,只要大于4就行,囧。
灵魂腐蚀 该用户已被删除
13#
发表于 2015-4-11 06:09:09 | 只看该作者
说点我烦的低级错误吧,曾经有次插入mysql的时间 弄了300年结果老报错,其实mysql的时间是有限制的,大概是到203X年  具体的记不清啦,囧。
飘灵儿 该用户已被删除
14#
发表于 2015-4-22 02:46:53 | 只看该作者
当然这种网站的会员费就几十块钱。
老尸 该用户已被删除
15#
发表于 2015-4-30 03:11:55 | 只看该作者
实践是检验自己会不会的真理。
活着的死人 该用户已被删除
16#
发表于 2015-6-14 01:20:22 | 只看该作者
使用zendstdio 写代码的的时候,把tab 的缩进设置成4个空格是很有必要的
只想知道 该用户已被删除
17#
发表于 2015-7-3 21:06:00 | 只看该作者
本人接触php时间不长,算是phper中的小菜鸟一只吧。由于刚开始学的时候没有名师指,碰过不少疙瘩,呗很多小问题卡过很久,白白浪费不少宝贵的时间,在次分享一些子的学习的心得。
透明 该用户已被删除
18#
发表于 2015-7-7 04:13:03 | 只看该作者
装在C盘下面可以利用windows的ghost功能可以还原回来(顺便当做是重转啦),当然啦我的编译目录要放在别的盘下,不然自己的劳动成果就悲剧啦。
柔情似水 该用户已被删除
19#
发表于 2015-7-15 11:13:07 | 只看该作者
建议加几个专业的phper的群,当然啦需要说话的人多,一处一点问题能有人回答你的,当然啦要让人回答你的问题,平时就得躲在里面聊天,大家混熟啦,愿意回答你问题的人自然就多啦。
谁可相欹 该用户已被删除
20#
发表于 2015-7-22 01:49:07 | 只看该作者
刚开始安装php的时候,我图了个省事,把php的扩展全都打开啦(就是把php.ini 那一片 extension 前面的冒号全去掉啦),这样自然有好处,以后不用再需要什么功能再来打开。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-4-29 17:57

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表