PHP

構文
int strcmp(string $str1 , string $str2 )
phpコード

$cftA = "Tokyo";$cftB = "Tokyo";$cftC = "TokyoHulu";if( ...

PHP

説明
strcmp ( string $str1 , string $str2 ) : int
この比較は大文字小文字を区別することに注意してください。
str1 最初の文字列。
str2 次の文字列。 ...

PHP

構文
const 定数名 = 値;
define(定数名, 値);
1.constの使用例
const cft = “test data”;
echo cft .R ...

PHP

関数説明
1.string implode ( array $pieces )
$glue 配列要素の間に挿入する文字列を指定します。
$pieces 文字列に変換する配列を指定します。
返り値 配列 ...

PHP

構文
substr ( string $string , int $start ) : string

phpコード

$cft = “this is a tesr “; ...

PHP

1.連想配列のキーを取得
$city = array(“tokyo” => “111”, “osaka” => “222̶ ...

PHP

phpコード

$city = ;foreach ($city as $key => $value){ echo $key; echo $value; }

 

PHP

書式
nl2br ( string $string ) : string

例1
echo nl2br(“東京\n 川崎”);

実行結果
東京<br/> ...

PHP

サンプルコード

<?php//グローバル変数$m = "789"; function demofunc(){global $m; return $m;}print $m;print demofunc();?>

& ...

PHP

説明
関数の引数としてグローバル変数を渡す。

サンプルコード

<?php$m = "678"; function testfunc($m){return $m;}print $m; print test ...

PHP

サンプルコード

<?php//global変数$m = "777"; function testfunc(){$n = "888";//ローカル変数return $n;}print $m; print testfunc() ...

PHP

サンプルコード
$tt = 0;

var_dump((float)$tt === 0.0);
var_dump((float)$tt === 0);
var_dump((float)$tt == 0 ...

PHP

書式
call_user_func(callable $callback, mixed …$args): mixed
パラメータ callback で指定したユーザー定義のコールバック関数をコールします。 ...

PHP

サンプルコード
$cft = array(“php入門”, “Java入門”,”Swift入門”);

//配列=>JSON
$t ...

PHP

書式
parent::親クラスのメソッド名
使用例

<?phpclass User{//getMsgメソッド public function getMsg(){ return "study skill"." ...

PHP

説明
strtotime
英文形式の日付を Unix タイムスタンプに変換する
PHPコード

<?php//monthecho date("Y-m-d H:i:s") ." <br>\n ...

PHP

サンプルコード

<?php$con=mysqli_connect("localhost","username","password","database");if (mysqli_connect_errno()){ ech ...

PHP

サンプルコード

<?php$tt = getdate();echo "年:".$tt."<br/>\n";echo "月:".$tt."<br/>\n";echo "日:".$tt."<br/ ...