Skip to content

Instantly share code, notes, and snippets.

View JingwenTian's full-sized avatar
🎯
Focusing

JingwenTian JingwenTian

🎯
Focusing
View GitHub Profile
@JingwenTian
JingwenTian / html.md
Created October 20, 2014 13:29
HTML速查表
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
@JingwenTian
JingwenTian / README.md
Last active August 29, 2015 14:07 — forked from nikcub/README.md
<?php
/* File : Rest.inc.php
* Author : Arun Kumar Sekar
*/
class REST {
public $_allow = array();
public $_content_type = "application/json";
public $_request = array();
<?php
// This is the API, 2 possibilities: show the app list or show a specific app by id.
// This would normally be pulled from a database but for demo purposes, I will be hardcoding the return values.
function get_app_by_id($id)
{
$app_info = array();
// normally this info would be pulled from a database.
// build JSON array.
server
{
listen 80;
#listen [::]:80;
server_name m.v5mp.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/m.v5mp.com;
include none.conf;
#error_page 404 /404.html;
<?php
//模拟一个订单数组
$arr = array(
0 => array(
"o_id"=>"1",
"name"=>"田景文",
"tel"=>"18677216692",
"order_date"=>"1412146800" //10-1
),
1 => array(
@JingwenTian
JingwenTian / array_sort_by_key.php
Created October 9, 2014 16:54
php按照指定键值对二维数组排序
<?php
/* 二维数组按指定的键值排序
* $array 数组
* $key排序键值
* $type排序方式
*/
function array_sort($arr, $keys, $type = 'desc') {
$keysvalue = $new_array = array();
foreach ($arr as $k => $v) {
$keysvalue[$k] = $v[$keys];
@JingwenTian
JingwenTian / foreach_continue.php
Created October 9, 2014 16:17
PHP跳出嵌套的循环
<?php
foreach($array as $key => $value){
if($value == 5)break;
}
// 这是一种。
// 如果是嵌套的循环,用continue加数字也可以实现
foreach($array as $key => $value){
foreach($value as $key2 => $value2){

URL-rewriting for klein PHP router

Why rewrite URLs? Check Wikipedia

Apache

Make sure AllowOverride is on for your directory, or put in httpd.conf

# Apache (.htaccess or httpd.conf)

RewriteEngine On