- 2024/11/21
- Category :
[PR]
×
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
ステップアップしていくブログです。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
$ cd /usr/local/src/php-5.x.xx/ext/zip
$ sudo /usr/local/bin/phpize $ sudo ./configure --with-php-config=/usr/local/bin/php-config $ sudo make $ sudo make test $ sudo make install $ sudo vi /usr/local/lib/php.ini + extension=zip.so $ sudo service httpd restart $ php -i | grep zip Registered PHP Streams => compress.zlib, php, file, glob, data, http, ftp, zip, phar gzip compression => enabled bzip2 compression => disabled (install pecl/bz2) zip Libzip version => 0.10.1
$ composer require psy/psysh:@stable
$ ./vendor/psy/psysh/bin/psysh Psy Shell v0.8.0 (PHP 7.1.0 — cli) by Justin Hileman >>> help help Show a list of commands. Type `help [foo]` for information about [foo]. Aliases: ? ls List local, instance or class variables, methods and constants. Aliases: list, dir dump Dump an object or primitive. doc Read the documentation for an object, class, constant, method or property. Aliases: rtfm, man show Show the code for an object, class, constant, method or property. wtf Show the backtrace of the most recent exception. Aliases: last-exception, wtf? whereami Show where you are in the code. throw-up Throw an exception out of the Psy Shell. trace Show the current call stack. buffer Show (or clear) the contents of the code input buffer. Aliases: buf clear Clear the Psy Shell screen. history Show the Psy Shell history. Aliases: hist exit End the current session and return to caller. Aliases: quit, q >>>
>> $arr = [1,2,3]; => [ 1, 2, 3, ] >>> 1 + 2; => 3 >>> function square($x) { ... return $x*$x*$x; ... } => null >>> square(4); => 64
<?php class ClassA { private $member_variable = 'A'; public function getMemberVariable() { return $this->member_variable; } } class ClassB extends ClassA { private $member_variable = 'B'; public function getMemberVariable() { return $this->member_variable; } } class ClassC extends ClassA { private $member_variable = 'C'; } $a = new ClassA(); $b = new ClassB(); $c = new ClassC(); echo $a->getMemberVariable()."\n"; echo $b->getMemberVariable()."\n"; echo $c->getMemberVariable()."\n";
$ php test.php A B A
<?php class ClassA { protected $member_variable = 'A'; public function getMemberVariable() { return $this->member_variable; } } class ClassB extends ClassA { protected $member_variable = 'B'; public function getMemberVariable() { return $this->member_variable; } } class ClassC extends ClassA { protected $member_variable = 'C'; } $a = new ClassA(); $b = new ClassB(); $c = new ClassC(); echo $a->getMemberVariable()."\n"; echo $b->getMemberVariable()."\n"; echo $c->getMemberVariable()."\n";
$ php test.php A B C
$ php -r "echo date('m', strtotime('+1 month'));" 05
$dt = new Carbon('next month'); echo $dt->format('m'); // 05
$dt = date('m', strtotime(date('Y-m-1').' +1 month')); echo $dt; // 04 $dt = new Carbon('first day of next month'); echo $dt->format('m'); // 04 $dt = new DateTime('first day of next month'); echo $dt->format('m'); // 04
指定した文字数で、指定した文字を用いて文字列を分割します。
function mb_wordwrap($string, $width, $break) { $result = []; $tmp_str = ''; $i = 0; while (mb_strlen($tmp_str) < mb_strlen($string)) { $str = mb_substr($string, $i*$width, $width); $result[] = $str; $tmp_str .= $str; $i++; } return implode($break, $result); }