test 2016-12-28


// dpm(variable_get('node_submitted_page'));
// //0

// dpm(variable_get('language_count'));
// //i3 = integer 3


// dpm($arr[123]);

// $arr = array('a'=>'b');
//// qin_tt_back($arr['ccc']);
//// //这样是不行的,因为ccc未定义的下标
//// qin_tt_back($arr['ccc'] = 'qinqiu');
//// //这样却是可以的,因为这里面有个赋值的过程

// global $install_state;
// dpm($install_state);
//没有值

//dpm(variable_get('install_profile'));
//standard
//这个是可以的

// if (isset($install_state['parameters']['profile'])) {
// $profile = $install_state['parameters']['profile'];
// }
//切记一点只要出现if isset就有可能是not set
//程序就是在有和没有之间选择并执行
//但都有可能

//cache_clear_all("*");
//这个函数运行不能正常

// drupal_flush_all_caches();
//dpm(variable_get('css_js_query_string'));
//ohsla2

//DEVEL模块的设置
//admin/config/development/devel

// $oct = 5000;
// $dec = base_convert($oct,10,2);
// dpm($dec);
// //1001110001000

// $str = base_convert(REQUEST_TIME, 10, 36);
// dpm($str);
// //ohsoe5

// variable_set('vat_tt',0);
// if(variable_get('vat_tt')){
// dpm('vat_tt_1');
// }else{
// dpm('vat_tt_0');
// }
// //打印出vat_tt_0

// dpm(drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0));


//dpm(__FILE__);
//D:\WWW\local\sites\all\modules\custom\directory_test\qin_tt.module
//当时正在运行的文件名

//dpm(dirname(__FILE__));
//D:\WWW\local\sites\all\modules\custom\directory_test

// dpm(conf_path());
// sites/default

// dpm(DRUPAL_ROOT);
// D:\WWW\local
// 也就是在index.php之上的层级
// 也是sites/includes/misc/modules/scripts/themes/.htaccess/cron.php/install.php的层级

//dpm(explode('/','/local/index.php'));
// //... (Array, 3 elements)
// //0 (String, 0 characters )
// 1 (String, 5 characters ) local
// 2 (String, 9 characters ) index.php


// dpm($_SERVER['HTTP_HOST']);
// //localhost

//dpm(implode('.', array('localhost')));
// //localhost

// dpm(array_slice(array('localhost','test_ua'),-1));
// //... (Array, 1 element)
// 0 (String, 7 characters ) test_ua

// $arr1 = array('a'=>'b');
// $arr2 = array('c'=>'d');
// dpm(array_intersect_key($arr1, $arr2));
// //ARRAY()

// dpm(VERSION);
// 7.50

// global $base_root;
// dpm($base_root);
//scheme+domain
// http://localhost

// dpm(_drupal_set_preferred_header_name());


// $str = str_pad('abcdefghijklmn',5000);
// dpm(gzencode($str, 9, FORCE_GZIP));
//首先你要有相应的文件库支持

// dpm('a\nb');
// dpm('a\rb');
//
// var_dump('a\nb');
// var_dump('a\rb');
//
// var_dump('a\n\rb');
// var_dump('a\r\nb');
// var_dump('a\tb');
//这些打印出来都没有什么意思,是什么就是什么

// dpm(REQUEST_TIME);
// 1481185197



// dpm($node_body);



// $match = preg_match('/[^\]]/','abc');
// dpm($match);

// dpm(is_file(base_path() . url('/sites/content/files/100g-200g-ofc-spotlight.jpg')));
//
// dpm(url('/sites/content/files/100g-200g-ofc-spotlight.jpg'));
// if(preg_match_all('/(?:\<p\>)?\[video-tabs:([^\]\\\]+)\](?:\<\/p\>)?([\s\S]+?)(?:\<p\>)?\[video-tabs-end\](?:\<\/p\>)?/i', '[video-tabs:a]abc[video-tabs-end]', $tabs_matches)) {
// dpm($tabs_matches);
//
// };

// dpm(check_plain('a/b/c.png'));
// dpm(check_plain('a/b/c.>png'));
// a/b/c.png
// a/b/c.&gt;png

// dpm(file_create_url('/sites/content/files/100g-200g-ofc-spotlight.jpg'));

// $input_exists = NULL;
// $array = array('a'=>array('b'=>array('c'=>'ddd')));
// $input_date = drupal_array_get_nested_value($array, array('a','b','c'), $input_exists);
// dpm($input_exists);
// dpm($input_date);
// 1
// ddd
//

// dpm(intval('abc123'));
// dpm(intval('123abc'));
// 0
// 123

// if($abc == 123){
// dpm("$abc == 123");
// }else{
// dpm("$abc is not set");
// }
// // is not set
//$abc undefined

// dpm(date('m-Y'));
// //12-2016

// $form = array('pbx_sets'=>array('#attributes' => ['id' => 'pbx-set-wrapper'],
// '#tree' => TRUE,
// '#type' => 'container'));
// dpm(render( $form ));
// <div id="pbx-set-wrapper"></div>

// $form = array( '#type' => 'fieldset',
// '#title' => t('PBX @set_num', ['@set_num' => 'abc']));
// dpm(render($form));
// <fieldset class="form-wrapper"><legend><span class="fieldset-legend">PBX abc</span></legend><div class="fieldset-wrapper"></div></fieldset>

// dpm(new DateTime('now'));
// //... (Object) DateTime
// date (String, 26 characters ) 2016-12-13 14:09:06.000000
// timezone_type (Integer) 3
// timezone (String, 13 characters ) Asia/Shanghai

// dpm(new DateTime('2016-11-11'));
// ... (Object) DateTime
// date (String, 26 characters ) 2016-11-11 00:00:00.000000
// timezone_type (Integer) 3
// timezone (String, 13 characters ) Asia/Shanghai

// $now = new DateTime('now');
// $eleven = new DateTime('2016-11-11');
//
// dpm($eleven->diff($now)); // invert = 0
// dpm($now->diff($eleven)); //invert = 1

// ... (Object) DateInterval
// y (Integer) 0
// m (Integer) 1
// d (Integer) 2
// h (Integer) 14
// i (Integer) 17
// s (Integer) 19
// weekday (Integer) 0
// weekday_behavior (Integer) 0
// first_last_day_of (Integer) 0
// invert (Integer) 0
// days (Integer) 32
// special_type (Integer) 0
// special_amount (Integer) 0
// have_weekday_relative (Integer) 0
// have_special_relative (Integer) 0

// ... (Object) DateInterval
// y (Integer) 0
// m (Integer) 1
// d (Integer) 2
// h (Integer) 14
// i (Integer) 17
// s (Integer) 19
// weekday (Integer) 0
// weekday_behavior (Integer) 0
// first_last_day_of (Integer) 0
// invert (Integer) 1
// days (Integer) 32
// special_type (Integer) 0
// special_amount (Integer) 0
// have_weekday_relative (Integer) 0
// have_special_relative (Integer) 0


// global $language;
// dpm($language);
// ... (Object) stdClass
// language (String, 2 characters ) en
// name (String, 7 characters ) English
// native (String, 7 characters ) English
// direction (String, 1 characters ) 0
// enabled (String, 1 characters ) 1
// plurals (String, 1 characters ) 0
// formula (String, 0 characters )
// domain (String, 0 characters )
// prefix (String, 0 characters )
// weight (String, 1 characters ) 0
// javascript (String, 0 characters )
// provider (String, 16 characters ) language-default

//没有装语言模块
//打印出来就是这样的状态信息


// foreach($results as $result){
// dpm($result);
// }
// //错误
//
// foreach($results = array(1) as $result){
// dpm($result);
// }
// //打印 1
//
// foreach($results = array() as $result){
// dpm($result);
// }
// //没有错误

// if(!$abc){
// dpm('not defined variable can be used in a if condition');
// }
// //会报错但也会正常的显示dpm里面的值
// Notice: Undefined variable: abc in qin_tt_init() (line 432 of D:\WWW\local\sites\all\modules\custom\directory_test\qin_tt.module).
// not defined variable can be used in a if condition


// dpm(field_valid_language(NULL,FALSE));
// //en

//dpm(node_load(12));
//field_attach_load('node', $node = array(12 => node_load(12)), $age = FIELD_LOAD_CURRENT, $options = array());
//dpm($node);


//unset($abc);
// //没有任何动静也没有任何反应

//$data = menu_tree_all_data('main_menu');
// $tree = menu_tree_output($data);
// dpm($tree);


// dpm(menu_get_object());
//在node/%是可以打印出来的
//在user/%下是打印不出来的

// dpm(_block_get_renderable_array(block_list('sidebar_left')));

//$register = drupal_get_form('user_register_form');
//dpm(render($register));

// dpm(menu_get_item('examples/ajax_example/progressbar'));

// dpm(url('a/b',array('a'=>'b')));
// $url = url('jaskon',array('a'=>'b'));
// dpm($url);
//这样打印是没有什么效果的
//原来options也是有套路的
//详情见url函数体
// drupal_goto($url);
// dpm($_GET);

// dpm(drupal_json_encode(array('a'=>'b')));
// //{"a":"b"}

// console.log(jQuery.extend({'a':'a'},{'a':'b'},{'a':'c'}));
// Object { a="c"}

//var str="Visit Microsoft!"
//console.log(str.replace(/Microsoft/, "W3School"));
//
// var url = '/nojs/abc';
// console.log(url.replace(/\/nojs(.*?)/g, '/ajax$1'));


// //var str="Visit Microsoft!"
// console.log(str.replace(/Microsoft/, "W3School"));
//
// var url = '/nojs/abc';
// console.log(url.replace(/\/nojs(.*?)/g, '/ajax$1'));
//
// var url = '/nojs/##$';
// console.log(url.replace(/\/nojs(\/|$|\?|&|#)/g, '/ajax$1'));
//第三个理解不了

//var replace = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
//for (character in replace) {
// console.log(character);
// console.log(replace.character);
//}
//character分别打印出下标
//replace.character分别打印出&amp;,&quot;,&lt;,&gt;

//$abc = module_enable(array('abc'));
//dpm($abc);
//空


// module_load_include('inc', 'node', 'node.pages');
// $form = node_form($form, $form_state, node_load(12));
// dpm($form);


// dpm(node_load(12));
// $wrapper = entity_metadata_wrapper('node', node_load(12));
// var_dump($wrapper);

// dpm(strpos('title_field_', 'title'));
// dpm(strpos('title', 'field_') != 0);
// dpm(strpos('title', 'field_') != FALSE);
//
// if(strpos('title_field_', 'abc') != 0){
// dpm('not 000');

// }

// dpm(empty($abc));
// //1

//dpm(node_form($form = array(),$form_state= array(),node_load(11)));

// $title_original = '<em>abcdefg</em>';
// $title = filter_xss($title_original, array('em', 'sub', 'sup'));
// dpm($title);
// dpm(check_plain($title_original));
// dpm(strip_tags($title_original));

// dpm(is_array($abc));
//Error messageNotice: Undefined variable: abc in qin_tt_init() (line 541 of D:\WWW\local\sites\all\modules\custom\directory_test\qin_tt.module).
//0
//不仅空而且报错

//$abc = 'abc';
//dpm(count($abc));
//1


// dpm(views_get_enabled_views());
// ... (Array, 5 elements)
// abc (Object) view
// archive (Object) view
// yearly_archive (Object) view
// article_expose_view_test (Object) view
// where_clause (Object) view

// dpm(views_fetch_plugin_data());

// $arr = array(
// '#type' => 'container',
// 'title' => array('#markup' => '<h3>Press Release feed tags</h3>'),
// );
// dpm(drupal_render($arr));
//
// <div><h3>Press Release feed tags</h3></div>
//
// $arr = array(
// '#type' => 'container',
// '#title' => array('#markup' => '<h3>Press Release feed tags</h3>'),
// );
// dpm(drupal_render($arr));
// <div></div>

// preg_match_all('/\d+/', 'abc12abc12', $blog_matches);
// dpm($blog_matches);
// ... (Array, 1 element)
// 0 (Array, 2 elements)
// 0 (String, 2 characters ) 12
// 1 (String, 2 characters ) 12


//preg_match_all('/\d*+/', 'abc12abc12', $blog_matches);
//会匹配到15个元素

// preg_match_all('/\d+?/', 'abc12abc12', $blog_matches);
// dpm($blog_matches);
// ... (Array, 1 element)
// 0 (Array, 4 elements)
// 0 (String, 1 characters ) 1
// 1 (String, 1 characters ) 2
// 2 (String, 1 characters ) 1
// 3 (String, 1 characters ) 2

// /(?:\<p\>)?\[blog\-feed:([^:\]]*):?([^\]]*)\](?:\<\/p\>)?/i

// if (preg_match_all(qin_tt_get_regex('blog-feed'), '[blog-feed:123:123-1]abc[blog-feed:456:456-1]', $blog_matches) ) {
// dpm($blog_matches);
// $blog_count = count($blog_matches[0]);
// for ($i = 0; $i < $blog_count; $i++) {
// if (!empty($blog_matches[2][$i])) $blog_tags[] = $blog_matches[2][$i];
// }
// }
//
// ... (Array, 3 elements)
// 0 (Array, 2 elements)
// 0 (String, 21 characters ) [blog-feed:123:123-1]
// 1 (String, 21 characters ) [blog-feed:456:456-1]
// 1 (Array, 2 elements)
// 0 (String, 3 characters ) 123
// 1 (String, 3 characters ) 456
// 2 (Array, 2 elements)
// 0 (String, 5 characters ) 123-1
// 1 (String, 5 characters ) 456-1

//
// drupal_set_title('addfd');
// dpm('aa');

// $output = '<a>dddd</a>';
// $pattern = "/&lt;(\/?)(". "<em>|<sup>|<sub>" .")&gt;/i";
// $output = preg_replace($pattern, '', $output);
// dpm($output);
// dpm('test');
//// <em>sadfasda</em>

// $output = '&lt;em&gt;dddd&lt;/em&gt;';
// $tag = "em|sup|sub";
// $pattern = "/&lt;(\/?)(". $tag .")&gt;/i";
// $output = preg_replace($pattern, '<$1$2>', $output);
// dpm($output);
// //<em>dddd</em>

// $output = '&lt;a&gt;dddd&lt;/a&gt;';
// $tag = "em|sup|sub";
// $pattern = "/&lt;(\/?)(". $tag .")&gt;/i";
// $output = preg_replace($pattern, '<$1$2>', $output);
// dpm($output);
// //&lt;a&gt;dddd&lt;/a&gt;

// $output = '&lt;em&gt;dddd&lt;/em&gt;';
// $tag = "em|sup|sub";
// $pattern = "/&lt;(\/?)(". $tag .")&gt;/i";
// $output = preg_replace($pattern, '<$1----$2>', $output);
// dpm($output);
// //<----em>dddd</----em>

// $output = '&lt;em&gt;dddd&lt;/em&gt;';
// $tag = "em|sup|sub";
// $pattern = "/&lt;(\/?)(". $tag .")&gt;/i";
// $output = preg_replace($pattern, '0', $output);
// dpm($output);
// //0dddd0
//可以看出preg_match是匹配一段然后再匹配一段
//不是一次匹配然后什么都不管了

// $output = '&lt;em&gt;dddd&lt;/em&gt;';
// $tag = "em|sup|sub";
// $pattern = "/&lt;(\/?)(". $tag .")&gt;/i"; //只是很小的代码小段可以不断的去匹配
// $output = preg_match_all($pattern, $output,$matches);
// dpm($output); //变成了1
// dpm($matches);
// ... (Array, 3 elements)
// 0 (Array, 2 elements)
// 0 (String, 10 characters ) &lt;em&gt;
// 1 (String, 11 characters ) &lt;/em&gt;
// 1 (Array, 2 elements)
// 0 (String, 0 characters )
// 1 (String, 1 characters ) /
// 2 (Array, 2 elements)
// 0 (String, 2 characters ) em
// 1 (String, 2 characters ) em


// $output = '&amp;a;';
// $pattern = "/&amp;([a-z0-9#]+);/";
// $output = preg_replace($pattern, '&$1;', $output);
// dpm($output);
// //&amp;a
// //&a;


// module_enable(array('ctools'));

// ctools_include('export');
// //一定要加载这个export.inc
// dpm(ctools_export_load_object('variable'));
// //这样就把所有的变量都打印出来了


//dpm(date('Y-m-d','1482371370'));
//2016-12-22

// dpm(module_exists('ctools'));

// drupal_get_schema('variable',TRUE);

// ctools_include('export');
//dpm(ctools_export_load_object('variable'));

// dpm(unserialize(array('a','b')));
//Warning: unserialize() expects parameter 1 to be string, array given in qin_tt_init() (line 715 of D:\WWW\local\sites\all\modules\custom\directory_test\qin_tt.module).


// $tt = 1;
// $a = $tt ++;
// dpm($a);
// dpm($tt);
// //1
// //2
// $tt = 1;
// $a = ++ $tt ;
// dpm($a);
// dpm($tt);
//2
//2

// $abc = 'abc';
// $abc = &drupal_static('qin_tt_abc');
// dpm($abc); // ''空
// dpm(qin_tt_abc()); // efg
//https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/drupal_static/7.x
//这个函数的作用相当于形成一个中央收集器
//形成一个GLOBAL


// dpm('\n\nabc\n\nabc');
// //\n\nabc\n\nabc
// var_dump('\n\nabc\n\nabc');
// //string '\n\nabc\n\nabc' (length=14)

// dpm(base_path());
///local/
//前后都带/很好很特别



// dpm('abc');

// $cid = array(1,2,3);
// $spliced = array_splice($cid, 0, 1);
// dpm($cid);
// dpm($spliced);
//
// ... (Array, 2 elements)
// 0 (Integer) 2
// 1 (Integer) 3
//
// ... (Array, 1 element)
// 0 (Integer) 1

// $keys = array('foo', 5, 10, 'bar');
// $a = array_fill_keys($keys, 'banana');
// print_r($a);
//
// Array
// (
// [foo] => banana
// [5] => banana
// [10] => banana
// [bar] => banana
// )

// dpm(qin_tt_abc());
//abc -
//一旦是返回一个数组则情况就不同了


//dpm(addcslashes('%\_%', '\%_'));
//\%\\\_\%

//$a = 0;
//dpm(is_scalar($a));
//1


// $a = array(1,12,34);
// dpm(is_scalar($a));\
// //空

//$a = 1;
//dpm($a++);
//1

// dpm(intval(FALSE));
//0

// dpm(array_reverse(array(1,2,3)));
// ... (Array, 3 elements)
//
// 0 (Integer) 3
// 1 (Integer) 2
// 2 (Integer) 1

//$abc = '123';
//$e = !empty($abc) && $abc;
//dpm($e);
//1

// dpm(menu_get_custom_theme());
// dpm('aa');
//空白

// dpm(!empty($abc));
//打印空但没有报错

// dpm(empty($abc));
//打印1没有报错

//dpm('a'.PHP_EOL.'b');
// //a
// b
//这种常量代码也认

// dpm('a\nb');
// //a\nb
//这种代码不认

//有的代码不好懂就要重点抓住旋涡的地方
//就好比长江回旋窝

// var_dump($testfile);
// extract($_FILES, EXTR_SKIP);
// var_dump($testfile);
// var_dump($testfile['tmp_name']);
// EXTR_SKIP
// 如果有冲突,不覆盖已有的变量。


// dpm( 6 > 3);
// //1


//$str = "Hello world!";
//$str = str_replace('/[e]*?/',"Shanghai",$str);
//似乎没有反应
// $str = str_replace('Hello',"Shanghai",$str);
// //Shanghai world!
//dpm($str);

// $output = '';
// $colgroups = array(
// // COLGROUP with one COL element.
//
//// array(
//// array(
//// 'class' => array('funky'), // Attribute for the COL element.
//// ),
//// array(
//// 'class' => array('funky-apk'), // Attribute for the COL element.
//// ),
//// ),
//
// // Colgroup with attributes and inner COL elements.
// array(
// 'data' => array(
// array(
// 'class' => array('funky'), // Attribute for the COL element.
// ),
// array(
// 'class' => array('funky-abc'), // Attribute for the COL element.
// ),
// ),
// 'class' => array('jazzy'), // Attribute for the COLGROUP element.
// ),
// );
//
// if (count($colgroups)) {
// foreach ($colgroups as $number => $colgroup) {
// $attributes = array();
//
// // Check if we're dealing with a simple or complex column
// if (isset($colgroup['data'])) {
// foreach ($colgroup as $key => $value) {
// if ($key == 'data') {
// $cols = $value;
// }
// else {
// $attributes[$key] = $value;
// }
// }
// }
// else {
// $cols = $colgroup;
// }
//
// // Build colgroup
// if (is_array($cols) && count($cols)) {
// $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
// $i = 0;
// foreach ($cols as $col) {
// $output .= ' <col' . drupal_attributes($col) . ' />';
// }
// $output .= " </colgroup>\n";
// }
// else {
// $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
// }
// }
// }

// dpm($colgroups);
// dpm($output);

//dpm(drupal_attributes(array('a'=>'b')));
// a="b"
// dpm(drupal_attributes(array(array('a'=>'b'))));
// 0="b"

//dpm($_SERVER['HTTP_HOST']);
////localhost

// $arr = array('aa','bb','cc');
// dpm(array_slice($arr, -1));

// ... (Array, 1 element)
// 0 (String, 2 characters ) cc

// dpm(array_slice($arr, 1));

// ... (Array, 2 elements)
// 0 (String, 2 characters ) bb
// 1 (String, 2 characters ) cc


// dpm(array_slice($arr, 1,2));
//
// ... (Array, 2 elements)
// 0 (String, 2 characters ) bb
// 1 (String, 2 characters ) cc
//请记住一点array_slice返回的也是array

//dpm($_SERVER['HTTP_HOST']);
//localhost

//dpm($_SERVER['REMOTE_ADDR']);
//::1

// dpm(request_path());
// node/13
// http://localhost/local/node/13

//dpm(strlen('我想你可以的'));
//18
//utf-8下一个汉字是3个Byte,但一个字母就是一个Byte
//但drupal_strlen就能得出汉字的个数

//dpm(preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', '[host]'));
//1

//global $base_url;
// dpm($base_url);
// //http://localhost/local
//
// global $base_root;
// dpm($base_root);
// //http://localhost


//dpm(parse_url('http://www.example.com/drupal'));
//
// ... (Array, 3 elements)
// scheme (String, 4 characters ) http
// host (String, 15 characters ) www.example.com
// path (String, 7 characters ) /drupal

// $base_url_a = 'http://www.example.com';
// $base_url_b = 'http://www.example.com:8888';
// $base_url_c = 'http://www.example.com/drupal';
// $base_url_d = 'https://www.example.com:8888/drupal';

// dpm(parse_url($base_url_a));
//
// ... (Array, 2 elements)
//
// scheme (String, 4 characters ) http
// host (String, 15 characters ) www.example.com


// dpm(parse_url($base_url_b));
//
// ... (Array, 3 elements)
//
// scheme (String, 4 characters ) http
// host (String, 15 characters ) www.example.com
// port (Integer) 8888


// dpm(parse_url($base_url_c));
//
// ... (Array, 3 elements)
//
// scheme (String, 4 characters ) http
// host (String, 15 characters ) www.example.com
// path (String, 7 characters ) /drupal


// dpm(parse_url($base_url_d));
//
// ... (Array, 4 elements)
//
// scheme (String, 5 characters ) https
// host (String, 15 characters ) www.example.com
// port (Integer) 8888
// path (String, 7 characters ) /drupal

// $base_url_dd = 'https://www.example.com:8888/drupal';
// if (isset($base_url_dd)) {
// // Parse fixed base URL from settings.php.
// $parts = parse_url($base_url_dd);
// if (!isset($parts['path'])) {
// $parts['path'] = '';
// }
// $base_path = $parts['path'] . '/';
// // Build $base_root (everything until first slash after "scheme://").
// $base_root = substr($base_url_dd, 0, strlen($base_url) - strlen($parts['path']));
// }
// dpm($base_root);
// //https://www.example.com:8888
posted @ 2016-12-28 13:09  qqisnow2021  阅读(188)  评论(0编辑  收藏  举报