ini_set('display_errors', "On");
ini_set('error_reporting', E_ALL);
2019年2月14日木曜日
2019年1月24日木曜日
php DateTime diff
DateTime比較するには、diffを使います。
$datetime = new DateTime("20190101");
$today_dt = new DateTime();
// $datetimeと現在の日付を比較する、$datetime - $today_dt の感じ
$interval = $datetime->diff($today_dt);
どっちが後ろ(大きい)かは、$interval['invert']が1の場合、$datetimeのほうが大きい。
$datetime = new DateTime("20190101");
$today_dt = new DateTime();
// $datetimeと現在の日付を比較する、$datetime - $today_dt の感じ
$interval = $datetime->diff($today_dt);
どっちが後ろ(大きい)かは、$interval['invert']が1の場合、$datetimeのほうが大きい。
2019年1月19日土曜日
symfony Timestampable
1)StofDoctrineExtensionsBundleをインストール
composer require stof/doctrine-extensions-bundle
2)Activating Timestampable
config
stof_doctrine_extensions:
default_locale: ja_JP
orm:
default:
timestampable: true
3)Entityに以下追加
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
class User implements UserInterface
{
use TimestampableEntity;
......
4)bin/console make:migration
5)bin/console doctrine:migrations:migrate
2017年3月27日月曜日
cakephp2 Call to undefined functionエラー
コントローラーに定義したfunctionを呼び出す際、表記エラーになった。
function定義
function isAuthorizedUserProj($proj_id) {
......
}
ほかのfunctionから呼ぶ出す
if (isAuthorizedUserProj($id)) {
......
}
調べたところ、
In general you need to use $this-> when accessing class methods and variables.
ということで、if ($this->isAuthorizedUserProj($id))に変更すればOK
function定義
function isAuthorizedUserProj($proj_id) {
......
}
ほかのfunctionから呼ぶ出す
if (isAuthorizedUserProj($id)) {
......
}
調べたところ、
In general you need to use $this-> when accessing class methods and variables.
ということで、if ($this->isAuthorizedUserProj($id))に変更すればOK
2017年3月3日金曜日
PHPで複数のfileをupload
HTML側
<form method="POST" enctype="multipart/form-data" action="merge.php">
<input type="file" name="upload_file[]" multiple id="file">
<input type="submit" name="submit" value="upload" />
PHP側
<?php
if(count($_FILES['upload_file'])) {
foreach($_FILES['upload_file'] as $file) {
print_r($file);
}
}
参考:https://davidwalsh.name/multiple-file-upload
<form method="POST" enctype="multipart/form-data" action="merge.php">
<input type="file" name="upload_file[]" multiple id="file">
<input type="submit" name="submit" value="upload" />
PHP側
<?php
if(count($_FILES['upload_file'])) {
foreach($_FILES['upload_file'] as $file) {
print_r($file);
}
}
参考:https://davidwalsh.name/multiple-file-upload
2016年9月10日土曜日
macのphpを7に更新
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
sudo apachectl restartあるいは
brew search php@7
そして、install versionを選択する
brew install php@7.2
参考ページ:https://coolestguidesontheplanet.com/upgrade-php-on-osx/
https://qiita.com/yamatmoo/items/4ff2fe1785f771e67e08
登録:
投稿 (Atom)