PHP - yagisawatakuya/Wiki GitHub Wiki
ダブルコーテーションでおこなう
http://zeropuro.com/blog/?p=139
var_dump(情報を出力する変数)
・Cookieが削除されるまで保存する
・プラウザを閉じるまで保存する
<?php
echo "test";
echo "test'. $test .'test01";
echo "test{$test}test01";
print "test";
?>
// function_exists( 関数 )
var_dump( function_exists('test') );
参考:https://whitebear-seo.com/wordpress-conditional-mobile-pc/
function is_iphone() {
$is_iphone = (bool) strpos($_SERVER['HTTP_USER_AGENT'],'iPhone');
if ($is_iphone) {
return true;
} else {
return false;
}
}
header('Location: https://www.test.jp/');
exit();
https://lab.syncer.jp/Web/PHP/Snippet/5/
http://www.flatflag.nir87.com/redirect-44
https://qiita.com/bossunn24/items/2d1a79d16d2bbf5947e9
$_SERVER["HTTPS"]
$_SERVER["HTTP_HOST"]
$_SERVER["REQUEST_URI"]
$_SERVER["PHP_SELF"]
$_SERVER["SERVER_NAME"]
$_SERVER["DOCUMENT_ROOT"]
$_SERVER["HTTP_USER_AGENT"]
http://php.net/manual/ja/reserved.variables.server.php
$value = "テスト";
if (isset($value)) {
echo "中身は入っています";
}
$value = "テスト";
if (!empty($value)) {
echo "中身は入っています";
}
$foo = NULL;
var_dump(is_null($inexistent), is_null($foo));
str_replace('検索文字列', '置換文字列', '検索対象の文字');
https://www.sejuku.net/blog/23430
$email = '[email protected]';
$domain = strstr($email, '@');
echo $domain; // @example.com と表示します
$user = strstr($email, '@', true); // PHP 5.3.0 以降
echo $user; // name と表示します
http://php.net/manual/ja/function.strstr.php
echo mb_substr('文字列', 0, 100, 'UTF-8'), '…';
// <p> と <a> は許可します
echo strip_tags($text, '<p><a>');
function branch($branch) {
// branch('url');
if ($branch == "url") {
echo 'url';
}
// branch('shop');
if ($branch == "shop") {
echo 'shop';
}
}
$i = 0;
foreach ($infos as $info) {
if($i >= 3){
break;
}
echo $visit_info['date'];
$i++;
}
print((empty($_SERVER["HTTPS"]) ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);