Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | devwiki:php [2022/11/16 16:16] (current) – [Python to Php] ying | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== PHP and SQL ====== | ||
+ | |||
+ | * select today data entry < | ||
+ | * ref: date related: https:// | ||
+ | * select current week data entry with option of week start day < | ||
+ | where YEARWEEK(`time_entry`) = YEARWEEK(CURDATE()) | ||
+ | where YEARWEEK(`time_entry`, | ||
+ | * Note: weekofyear return week number, means previous year will return too < | ||
+ | * select current month data entry < | ||
+ | * select past 24 hr < | ||
+ | * select past 7 days < | ||
+ | * select past 1 month time < | ||
+ | |||
+ | |||
+ | * array related < | ||
+ | // sort array | ||
+ | sort($my_list); | ||
+ | </ | ||
+ | |||
+ | * unicode data insert, make sure | ||
+ | - database table' | ||
+ | CREATE TABLE info_table ( | ||
+ | id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
+ | name varchar(50) NOT NULL, | ||
+ | edit_time DATETIME NOT NULL | ||
+ | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | ||
+ | </ | ||
+ | - make sure database connect is set to utf8mb4 mode in php before query and insert< | ||
+ | mysqli_set_charset($con, | ||
+ | </ | ||
+ | - make sure charset is declared in html < | ||
+ | <meta http-equiv=" | ||
+ | </ | ||
+ | ====== Php Date and Time Related ====== | ||
+ | * all time info < | ||
+ | date(' | ||
+ | date(' | ||
+ | date(" | ||
+ | </ | ||
+ | |||
+ | * get current week range (monday to sunday) or any day's week range <code php> | ||
+ | //ref: https:// | ||
+ | function rangeWeek($datestr) { | ||
+ | date_default_timezone_set(' | ||
+ | $date_val = strtotime($datestr); | ||
+ | return array ( | ||
+ | " | ||
+ | " | ||
+ | ); | ||
+ | } | ||
+ | echo rangeWeek(' | ||
+ | </ | ||
+ | |||
+ | * show during time range: https:// | ||
+ | |||
+ | ====== Python to Php ====== | ||
+ | |||
+ | ^ ^ python ^ php ^ | ||
+ | | string operation | word.strip() | trim($word) | | ||
+ | | | word[1:5] | substr($word, | ||
+ | | | word[1:] | substr($word, | ||
+ | | | prefix+subfix | $prefix.$subfix | | ||
+ | | | text.replace(' | ||
+ | | | text.lower() | strtolower($text) | | ||
+ | | | text.startswith(prefix) | ? | | ||
+ | | list operation | res_list = [x.strip() for x in txt.split(' | ||
+ | | | | < | ||
+ | | | res_list.append(tmp_img) | array_push($res_list, | ||
+ | | | | $res_list[] = $tmp_img; | | ||
+ | | | for each in word_list: | foreach($word_list as $each){} | | ||
+ | | | if id in check_list: | if(in_array($id, | ||
+ | | logic | if mark == '#': | ||
+ | |||
+ | < | ||
+ | php: | ||
+ | $tmp_path = $path.strtolower(str_replace(' | ||
+ | $tmp_img = sprintf('< | ||
+ | array_push($res_list, | ||
+ | join(" | ||
+ | |||
+ | python: (human logic writing) | ||
+ | tmp_path = path + each[1: | ||
+ | tmp_img = '< | ||
+ | res_list.append(tmp_img) | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | ====== Use PHP as HTML File output process ====== | ||
+ | |||
+ | * other than serve php page through apache server, php in commandline also can be used to create html local page. | ||
+ | * cmd code for render php to html file< | ||
+ | cd php_root_path | ||
+ | php.exe D: | ||
+ | </ | ||