devwiki:php

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revisionBoth sides next revision
devwiki:php [2021/12/14 16:56] – [Php Date and Time Related] yingdevwiki:php [2021/12/23 17:41] – [PHP and SQL] ying
Line 16: Line 16:
 // sort array // sort array
 sort($my_list); sort($my_list);
 +</code>
 +
 +  * unicode data insert, make sure
 +    - database table's charset is utf8mb4 in sql<code>
 +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;
 +</code>
 +    - make sure database connect is set to utf8mb4 mode in php before query and insert<code>
 +mysqli_set_charset($con, "utf8mb4");
 +</code>
 +    - make sure charset is declared in html <code>
 +<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 </code> </code>
 ====== Php Date and Time Related ====== ====== Php Date and Time Related ======
Line 50: Line 65:
 |  | text.startswith(prefix) | ? | |  | text.startswith(prefix) | ? |
 | list operation | res_list = [x.strip() for x in txt.split('\n')] | $res_list = array_map('trim', explod('\n', $txt)) | | list operation | res_list = [x.strip() for x in txt.split('\n')] | $res_list = array_map('trim', explod('\n', $txt)) |
-logic | for each in word_list: | foreach($word_list as $each){} | +| | <code>$res_list = array_map('trim', preg_split("/\r\n|\n|\r/", $selected) ); // ok for text</code>
- | if mark == '#': pass; elif mark == '*' | if($mark==="#"){} elseif($mark==="*"){} |+| | res_list.append(tmp_img) | array_push($res_list, $tmp_img); | 
 +| |  | $res_list[] = $tmp_img; | 
 +| for each in word_list: | foreach($word_list as $each){} | 
 +| if id in check_list: | if(in_array($id, $check_list)){} | 
 +| logic | if mark == '#': pass; elif mark == '*' | if($mark==="#"){} elseif($mark==="*"){} |
  
 <code> <code>
 php:  php: 
-$tmp_path = path.strtolower(str_replace(' ','_', trim(substr($each,1)))).'.jpg'+$tmp_path = $path.strtolower(str_replace(' ','_', trim(substr($each,1)))).'.jpg'
 +$tmp_img = sprintf('<br><img src="%s">', $tmp_path); 
 +array_push($res_list, $tmp_img); 
 +join("\n",$res_list); 
 python: (human logic writing) python: (human logic writing)
 tmp_path = path + each[1:].strip().replace(' ','_').lower()+ '.jpg' tmp_path = path + each[1:].strip().replace(' ','_').lower()+ '.jpg'
 +tmp_img = '<br><img src="{0}">'.format(tmp_path)
 +res_list.append(tmp_img)
 +'\n'.join(res_list)
 </code> </code>
  • devwiki/php.txt
  • Last modified: 2022/11/16 16:16
  • by ying