アプリ関連ニュース
- 2020年5月08日
- 技術情報
[Laravel] バリデーションエラーメッセージの日本語化
nishida at 2020年05月08日 10:00:08
- 2020年5月01日
- 技術情報
[Laravel]バリデーション機能の使用
nishida at 2020年05月01日 10:00:30
- 2020年4月27日
- 技術情報
Isset VS Empty In PHP
Today I will walk through the difference between isset & empty , build in functions in PHP.
Iseet
It checks the variable to see if it has been set, in other words, it checks to see if the variable is any value except NULL or not assigned a value. ISSET returns TRUE if the variable exists and has a value other than NULL. That means variables assigned a ” “, 0, “0”, or FALSE are set, and therefore are TRUE for ISSET.
Empty
It checks to see if a variable is empty. Empty is interpreted as: ” ” (an empty string), 0 (0 as an integer), 0.0 (0 as a float), “0” (0 as a string), NULL, FALSE, array() (an empty array), and “$var;” (a variable declared, but without a value in a class.)
Lets do some comparisons.
Non declared variable
isset($novar) – Return FALSE
empty($novar) – Return TRUE
Null Variable
$null = NULL;
isset ($null) - Return FALSE
empty ($null) - Return TRUE
Empty String
$emptyString = "";
isset($emptyString) - Return TRUE
empty($emptyString) - Return TRUE
This will be the same result for zero case.
Boolean value
$tbl = TRUE;
$fbl = FALSE;
Isset . Will Return TRUE For Both Cases
Empty
empty($tbl) - Return FALSE
empty($fbl) - Return TRUE
Empty Array
$arr = [];
The result will be true for both isset and empty
Empty object
$obj = new stdClass ();
isset ($obj) – return TRUE
empty ($obj) – return FALSE
Note: Isset only accepts single variable within its parenthesis. Passing others will proceed to error. For example
isset(strtoupper($var)) – this will proceed to error.
By Yuuma
yuuma at 2020年04月27日 11:00:59
- 2020年4月24日
- 技術情報
[Laravel] Bladeテンプレートエンジン(2)ディレクティブ編
PHPフレームワーク「Laravel」を使用するにあたり、Viewの作成は、Bladeテンプレートエンジンを使用することが一般的です。
Bladeテンプレートエンジンを使用することでHTMLへのPHPの埋め込みが簡単におこなえるようになります。
今回は、Bladeテンプレートで使用できるディレクティブの紹介をおこないたいと思います。
nishida at 2020年04月24日 10:00:13
Android ダイアログを画面いっぱいに表示する
tanaka at 2020年04月22日 10:00:24