Skip to content

Instantly share code, notes, and snippets.

@kunit
kunit / aws-cloud9-php71-mysql57.sh
Last active August 29, 2018 11:37
AWS Cloud9 のPHP/MySQLのバージョンを PHP 7.1/MySQL 5.7 にするスクリプト
#!/bin/sh
sudo service mysqld stop
sudo yum -y erase mysql-config mysql55-server mysql55-libs mysql55
sudo yum -y install mysql57-server mysql57
sudo service mysqld start
sudo yum -y install php71 php71-cli php71-common php71-devel php71-mysqlnd php71-pdo php71-xml php71-gd php71-intl php71-mbstring php71-mcrypt php71-opcache php71-pecl-apcu php71-pecl-imagick php71-pecl-memcached php71-pecl-redis php71-pecl-xdebug
sudo alternatives --set php /usr/bin/php-7.1
curl -sS https://getcomposer.org/installer | php
@kunit
kunit / オブジェクト案のテスト
Created January 21, 2011 08:21
最低限度のもの
<?php
class Escaper {
public $value = null;
public $raw = null;
public function __construct($value, $charset = 'UTF-8') {
$this->value = htmlspecialchars($value, ENT_QUOTES, $charset);
$this->raw = $value;
}
public function __toString() {
@kunit
kunit / エスケープ案
Created January 21, 2011 06:47
元が配列である前提で解析して、最後の最後で _raw_xxx というキーを入れる
<?php
class Foo {
function h($text) {
$result = array();
$charset = 'UTF-8';
$this->_escape($text, $result, $charset);
return $result;
}
function _escape($values, &$result, $charset) {
foreach ($values as $key => $value) {