PHP code example of cool / common
1. Go to this page and download the library: Download cool/common library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cool / common example snippets
$data = [
"dataShow" => [
"conf"=>[
"key"=>"type",
"code"=>[
"order-data"=>"TA",
"change-data"=>"DATA.CUSTOMER_CHANGE_DATA",
"turn-data"=>"CUSTOMER.CRM_TURN_REGION",
"leads-data"=>"TASK.CRM_LEADS_QUERY",
"tag-data"=>"CONFIG.OS_CATEGORY",
"user-data"=>"CONFIG.OS_CATEGORY",
"see-phone"=>1,
]
],
"ata"=>"CONFIG.OS_CATEGORY",
"see-phone"=>"CONFIG.OS_CATEGORY",
]
],
"
$cfg = [
'formOpen' => '<form action="%s" method="%s">',
'text' => '<input type="text" name="%s" value="%s" />',
'select' => ['<select name="%s">', '<option%s value="%s">%s</option>', '</select>'],
'formEnd' => '</form>',
];
$form = new FormCore($cfg);
$form->addMultiData(['formOpen', ['', 'post']]);
$form->addData(['text', ['fname', 'carl']]);
$form->addData(['formEnd', []]);
echo $form->render();
//====================Test code ================================
header("content-type:text/html;charset=utf-8");
$categories = array(
array('id'=>1,'name'=>'电脑','pid'=>0),
array('id'=>2,'name'=>'手机','pid'=>0),
array('id'=>3,'name'=>'笔记本','pid'=>1),
array('id'=>4,'name'=>'台式机','pid'=>1),
array('id'=>5,'name'=>'智能机','pid'=>2),
array('id'=>6,'name'=>'功能机','pid'=>2),
array('id'=>7,'name'=>'超级本','pid'=>3),
array('id'=>8,'name'=>'游戏本','pid'=>3),
);
//$cate = new CategoryHelper();
$cate = CategoryHelper::render($categories);
$cate = CategoryHelper::format($categories);