phpsin
Ⅰ php函數設定參數類型
php 函數的參數類型可以指定為類名或數組類型array,比如
這樣是對的public function Right( My_Class $a, array $b )
這樣是錯的public function Wrong( string $a, boolean $b )
如果需要其他類型,需要在函數內部進行類型檢查
參考
http://www.php.net/manual/zh/functions.arguments.php
這一段
public function Right( My_Class $a, array $b )
tells first argument have to by object of My_Class, second an array. My_Class means that you can pass also object of class that either extends My_Class or implements (if My_Class is abstract class) My_Class. If you need exactly My_Class you need to either make it final, or add some code to check what $a really.
Also note, that (unfortunately) "array" is the only built-in type you can use in signature. Any other types i.e.:
public function Wrong( string $a, boolean $b )
will cause an error, because PHP will complain that $a is not an *object* of class string (and $b is not an object of class boolean).
So if you need to know if $a is a string or $b bool, you need to write some code in your function body and i.e. throw exception if you detect type mismatch (or you can try to cast if it's doable).
Ⅱ PHP程序算出NAN
你的電腦現在的配置算不出更多次冪了,所以返回錯誤
Ⅲ PHP如何進行三表查詢
你說的意思是 用php查詢mysql 3個表裡的語句 然後查詢 輸出 出來吧。
語句我給你寫下來 你只需要填表的名字就可以了。
<?php
$sin=mysql_connect('localhost','root','');
mysql_select_db('abc',$sin)
$ain=mysql_query( "select * from 你要查詢表的名字 "')
echo 「$ain」;
?>
沒看懂 追 希望能幫助您解決問題。
Ⅳ php算三角函數
cos — 餘弦
cosh — 雙曲餘弦
sin — 正弦
sinh — 雙曲正弦
tan — 正切
tanh — 雙曲正切
acos — 反餘弦
acosh — 反雙曲餘弦
asin — 反正弦
asinh — 反雙曲正弦
atan2 — 兩個參數的反正切
atan — 反正切
atanh — 反雙曲正切
Ⅳ php 求角度函數
abs --- 取絕對值
acos --- 取反餘弦值
asin --- 取反正弦值
atan --- 取反正切值
atan2 --- 取二個變數的反正切值
base_convert --- 轉換數值的進位方式
bindec --- 二進制轉十進制
ceil --- 取得大於指定數的最小整數值
cos --- 取餘弦值
decbin --- 十進制轉二進制
dechex --- 十進制轉十六進制
decoct --- 十進制轉八進制
deg2rad --- 將數值從度數轉成徑度
exp --- 取得自然對數的次方值
floor --- 取得小於指定數的最大整數值
getrandmax --- 取得最大亂數值
hexdec --- 十六進制轉十進制
log --- 自然對數
log10 --- 底為10的對數
max --- 傳回參數中最大值
min --- 傳回參數中最小值
mt_rand --- 取得亂數值
mt_srand --- 設定亂數種子
mt_getrandmax --- 取得亂數最大值
number_format --- 將數字字元串格式化
octdec --- 八進制轉十進制
pi --- 取得圓周率pi的值
pow --- 傳回次方項的值
rad2deg --- 轉換徑度值為度數
rand --- 產生亂數值
round --- 取四拾五入
sin --- 取正弦值
sqrt --- 取平方根值
srand --- 設定亂數種子
tan --- 取正切值
Ⅵ 關於用php製作統計
幫你改好了 可以直接運行 至於問題 你自己慢慢發現吧 如果有不懂的 再來問我
<html>
<HEAD>
<TITLE>particular</TITLE>
</HEAD>
<BODY>
<form name="particular" method="post" enctype="multipart/form-data" action="particular.php">
<table>
姓名:<input name="player" size="16" type="text" /><br>
學院:<input name="school" size="30" type="text" /><br>
項目:<input name="game" size="30" type="text" /><br>
團體:
破記錄<input name="teamb" type="checkbox" />
金<input name="teamj" type="checkbox" />
銀<input name="teamy" type="checkbox" />
銅<input name="teamt" type="checkbox" />
<br>
個人:
破記錄<input name="sinb" type="checkbox" />
金<input name="sinj" type="checkbox" />
銀<input name="siny" type="checkbox" />
銅<input name="sint" type="checkbox" />
<br>
<input name="submit" type="submit" />
<input name="reset" type="reset" />
</table>
</form>
</BODY>
</HTML>
PHP文件
<html>
<head>
<title>particular.php</title>
</head>
<body>
<?php
//$arr=array
// ( teamb => 12,
// teamb => 6,
// teamb => 4,
// teamb => 2,
// teamb => 6,
// teamb => 3,
// teamb => 2,
// teamb => 1,
// );
$player=$_POST["player"]; #接收數據
$school=$_POST["school"];
$game=$_POST["game"];
$teamb=(!empty($_POST["teamb"]))?'12':'0';
$teamj=(!empty($_POST["teamj"]))?'6':'0';
$teamy=(!empty($_POST["teamy"]))?'4':'0';
$teamt=(!empty($_POST["teamt"]))?'2':'0';
$sinb=(!empty($_POST["sinb"]))?'6':'0';
$sinj=(!empty($_POST["sinj"]))?'3':'0';
$siny=(!empty($_POST["siny"]))?'2':'0';
$sint=(!empty($_POST["sint"]))?'1':'0';
$counterFile = "counterfile.txt"; #定義txt記錄文本
//function displayCounter($counterFile$teamb) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num=$num+$teamb+$teamj+$teamy+$teamt+$sinb+$sinj+$siny+$sint; #加上得分
echo"".$school."最新更新<br>"; #顯示詳細更新情況
echo"姓名:".$player."<br>";
echo"項目".$game."<br>";
echo"成績".$teamb,$teamj,$teamy,$teamt,$sinb,$sinj,$siny,$sint."<br>";
echo"學院總成績".$num."分<br>";
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
//}
if (!file_exists($counterFile)) {
exec( "echo 0 > $counterFile"); #如果記數器文件不存在,新建它並設置內容為0
}
//displayCounter($counterFile);
?>
</body>
</html>