0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

気になった関数まとめ

Last updated at Posted at 2020-09-02

ini_set

``` ini_set( $varname , $newvalue ) ``` あらかじめ設定された[$varname](https://www.php.net/manual/ja/ini.list.php "$varname")を $newvalueの値に変更。

serialize

``` serialize( array('first' => 1, 'second'=>two) //a:2:{s:5:"first";i:1;s:6:"second";s:3:"two"} ``` 型:値{型:文字数:値;型:値}
型別の値
PHP:serialize-Manual User Contributed Notes 引用 > String s:size:value;

Integer
i:value;

Boolean
b:value; (does not store "true" or "false", does store '1' or '0')

Array
a:size:{key definition;value definition;(repeated per element)}

Null
N;

文字は長さと値、数字は値、真偽は1(真)か0(偽)

strpos

``` $haystack = 'abcdefg' $needle = 'e' echo strpos($haystack, $needle) //4 ```

$haystack 中で $needleが最初に現れる位置を返します。

time

``` echo time() //1599018369 ``` 現在時刻(2020/09/02 12:46)時点のUNIXスタンプを返す UNIXスタンプは協定世界時 (UTC) での1970年1月1日午前0時0分0秒から形式的な経過秒数)。

#CakePHP

newEntity

``` $entity = $this->{$tableName}->newEntity($requestData, ['validate' => false]); ``` $reqestData 配列 の ['validate' => 'false']にして、 {$requestData}table.php のvalidationを無効にしたentityを新たに作成して$entityに代入する。

set

``` public function set($name, $value){
$this->viewVars = $data + $this->viewVars;
return $this;

}
//$this->viewVars[$name => $value]


setでviewVarsにインデックスが$name,値が$valueの要素を追加する。
コントローラー側で $this->viewVars[$name] で呼び出すことができる。
画面の方のdebug kitの Variables 内にviewVarsが格納されている。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?