検索

PHPテンプレート解析クラス
  1. class template {
  2. private $vars = array();
  3. private $conf = '';
  4. private $tpl_name = 'index';// テンプレートが存在しない場合、現在のコントローラーが検索されます デフォルトのインデックス テンプレート
  5. private $tpl_suffix = '.html';//CONFIG がデフォルトのサフィックスで構成されていない場合、それが表示されます
  6. private $tpl_compile_suffix= '.tpl.php';//テンプレートをコンパイルしますpath
  7. private $template_tag_left = ' private $template_tag_right = '}>';//テンプレート右タグ
  8. private $template_c = '';//コンパイルディレクトリ
  9. private $template_path = '';//テンプレートのフルパス
  10. private $ template_name = '';//テンプレート名index.html
  11. //各テンプレートのタグを定義する要素
  12. private $tag_foreach = array('from', 'item' , 'key');
  13. private $tag_include = array('file');//現在、テンプレートのデフォルト パスの読み取りのみをサポートしています
  14. public function __construct($conf) {
  15. $this->conf = &$ conf;
  16. $this->template_c = $this ->conf['template_config']['template_c'];//コンパイルディレクトリ
  17. $this->_tpl_suffix = $this->tpl_suffix();
  18. }
  19. プライベート関数 str_replace($search, $ replace, $content) {
  20. if(empty($search) || empty($replace) || empty($content)) return false;
  21. return str_replace($ search, $replace, $content);
  22. }
  23. /**
  24. * preg_match_all
  25. * @param $pattern Regular
  26. * @param $content コンテンツ
  27. * @return array
  28. */
  29. プライベート関数 preg_match_all($pattern, $content) {
  30. if(empty($pattern) || empty($content)) core::show_error('テンプレート タグが見つかりませんでした!') ;
  31. preg_match_all("/".$this->template_tag_left.$pattern.$this->template_tag_right."/is", $content, $match) ;
  32. return $match;
  33. }
  34. /**
  35. * テンプレートファイルのサフィックス
  36. */
  37. public function tpl_suffix() {
  38. $tpl_suffix = empty($this->conf['template_config']['template_suffix'])
  39. $ this->tpl_suffix :
  40. $this->conf[ 'template_config']['template_suffix'] ;
  41. return $tpl_suffix;
  42. }
  43. /**
  44. * ここでは説明はありません
  45. * @return
  46. */
  47. public function assign($key, $ value) {
  48. $this->vars[$key] = $value;
  49. }
  50. /**
  51. * ページをレンダリングします
  52. * @param
  53. * 使用方法 1
  54. * $this->view->display('error', 'comm/');
  55. * デフォルトでは、TPL の次のディレクトリを指しますテンプレートなので comm/ tpl/comm/error.html です
  56. * 使用方法 2
  57. * $this->view->display('errorfile'); * デフォルトでは、コントローラー
  58. * たとえば、ドメイン名が http://heartphp/admin/index の場合、正しいパスは tpl/admin/index/errorfile.html です
  59. * @return
  60. */
  61. public function display($filename = '', $view_path = '') {
  62. $ tpl_path_arr = $this->get_tpl($filename, $view_path );//TPL のフルパスを取得し、パスと名前をポインターに転送します
  63. if(!$tpl_path_arr) core::show_error($filename.$this- >_tpl_suffix.'テンプレートが存在しません');
  64. //コンパイルを開始します
  65. $this->gt;view_path_param = $view_path;//ユーザーによって渡されたテンプレートとディレクトリ
  66. $this->compile();
  67. }
  68. /**
  69. * コンパイルコントローラー
  70. * @param
  71. * @return
  72. */
  73. プライベート関数compile() {
  74. $filepath = $this->template_path.$this->template_name;
  75. $compile_dirpath = $this->check_temp_compile();
  76. $vars_template_c_name = str_replace($this->tpl_suffix, '', $this->template_name);
  77. $include_file = $this->template_replace($this->read_file($filepath), $compile_dirpath , $vars_template_c_name);//Parse
  78. if($include_file) {
  79. $this- >read_config() && $config = $this->read_config();
  80. extract($this->vars, EXTR_SKIP);
  81. [url=home.php?mod=space&uid=48608]@include[/url ] $include_file;
  82. }
  83. }
  84. /**
  85. * 現在のプロジェクト構成ファイルを読み取ります
  86. */
  87. 保護関数 read_config() {
  88. if(file_exists(SYSTEM_PATH) .'conf/config.php')) {
  89. @include SYSTEM_PATH.'conf/ config.php';
  90. return $config;
  91. }
  92. return false;
  93. }
  94. /**
  95. * テンプレート構文の解析
  96. * @param $str content
  97. * @param $compile_dirpath テンプレートのコンパイル ディレクトリ
  98. * @param $vars_template_c_name テンプレートのコンパイル ファイル名
  99. * @return コンパイル済みの PHP テンプレート ファイル名
  100. */
  101. プライベート関数 template_replace($str, $compile_dirpath, $vars_template_c_name) {
  102. if(empty($str)) core::show_error('テンプレートの内容が空です!');
  103. / /コンパイルヘッダーを処理します
  104. $compile_path = $compile_dirpath.$vars_template_c_name.$this->tpl_compile_suffix;//ファイルをコンパイルします
  105. if(is_file($compile_path)) {
  106. //$header_content = $this->gt;get_compile_header( $コンパイル_パス);
  107. //$compile_date = $this->get_compile_header_comment($header_content);
  108. $tpl_filemtime = filemtime($this->template_path.$this->template_name);
  109. $compile_filemtime = filemtime($compile_path );
  110. //echo $tpl_filemtime.'=='.date('Y-m-d H:i:s', $tpl_filemtime).'
    ';
  111. //echo $compile_filemtime.'== ' .date('Y-m-d H:i:s', $compile_filemtime);
  112. //ファイルの有効期限が切れている場合は、コンパイルし、テンプレート タグに include が含まれているため、再コンパイルも行われます
  113. // インクルード内のファイルを変更する場合、非DEBUGモードではメインファイルを変更しないと現状インクルード内のファイルは再コンパイルされません。これも変更するか検討中です。とりあえず考えてなかったので、開発段階では必ずDEBUG=1モードをONにしてください。そうしないとインクルードファイルの変更が無効になります。有点罗嗦,不知道表述明確没
  114. if($tpl_filemtime > $compile_filemtime || DEBUG) {
  115. $ret_file = $this->compile_file($vars_template_c_name, $str, $compile_dirpath);
  116. } else {
  117. $ ret_file = $compile_path;
  118. }
  119. } else {///编译文件不存在创建他
  120. $ret_file = $this->compile_file($vars_template_c_name, $str, $compile_dirpath);
  121. }
  122. return $ret_file;
  123. }
  124. /**
  125. * テンプレートファイル本体
  126. * @param string $str content
  127. * @return html
  128. */
  129. private function body_content($str) {
  130. //解析
  131. $str = $this->parse($str);
  132. $header_comment = "作成日##" .time()."|Compiled from##".$this->template_path.$this->template_name;
  133. $content = " if(!define('IS_HEARTPHP')) exit('アクセスが拒否されました');/*{$header_comment}*/?>rn$str";
  134. return $content;
  135. }
  136. /**
  137. * 関連するテンプレート タグの解析を開始します
  138. * @param $content テンプレート コンテンツ
  139. */
  140. プライベート関数 parse($content) {
  141. //foreach
  142. $content = $this->parse_foreach($content);
  143. //include
  144. $content = $this->parse_include($content);
  145. //if
  146. $content = $this->parse_if ($content);
  147. //elseif
  148. $content = $this->parse_elseif($content);
  149. //模板标签公用部分
  150. $content = $this->parse_comm($content);
  151. //转はphp代码
  152. $content = $this->parse_php($content);
  153. return $content;
  154. }
  155. /**
  156. * デフォルトで echo が直接 の場合、 に変換されます。*/
  157. private function parse_echo($content) {
  158. }
  159. /**
  160. * PHP に変換します
  161. * @param $content html テンプレートのコンテンツ
  162. * @return html HTML を置き換えます
  163. */
  164. プライベート関数 parse_php($content){
  165. if(empty($content)) return false;
  166. $content = preg_replace("/".$this->template_tag_left. "(.+?)".$this->template_tag_right."/is", "", $content);
  167. return $content;
  168. }
  169. /**
  170. * if判断语句
  171. *
  172. * zhang
  173. *
  174. * liang
  175. *
  176. *張良
  177. *
  178. */
  179. プライベート関数 parse_if($content) {
  180. if(empty($content)) return false;
  181. //preg_match_all("/".$this->template_tag_left."ifs+(.*?)".$this ->template_tag_right."/is", $content, $match);
  182. $match = $this->preg_match_all("ifs+(.*?)", $content);
  183. if(!isset($match) [1]) || !is_array($match[1])) return $content;
  184. foreach($match[1] as $k => $v) {
  185. //$s = preg_split("/s+ /is", $v);
  186. //$s = array_filter($s);
  187. $content = str_replace($match[0][$k], "", $content);
  188. }
  189. return $content;
  190. }
  191. private function parse_elseif($content) {
  192. if(empty($content)) return false;
  193. //preg_match_all("/".$ this->template_tag_left."elseifs+(.*?)".$this->template_tag_right."/is", $content, $match);
  194. $match = $this->preg_match_all("elseifs+(.* ?)", $content);
  195. if(!isset($match[1]) || !is_array($match[1])) return $content;
  196. foreach($match[1] as $k => $v) {
  197. //$s = preg_split("/s+/is", $v );
  198. //$s = array_filter($s);
  199. $content = str_replace($match[0][$k], "", $ content);
  200. }
  201. return $content;
  202. }
  203. /**
  204. * 解析 include include标签不是实時更新当本体文件更新的時才更新标签内容,想想include生效请修正一下本体文件
  205. * 记录一下有時间开出版一当DEBUGモード的時候每次执行删除モ版编译文件
  206. * 使用方法
  207. * @param $content 模板内容
  208. * @return html
  209. */
  210. private function parse_include($content) {
  211. if(empty($content)) return false;
  212. //preg_match_all("/".$ this->template_tag_left."includes+(.*?)".$this->template_tag_right."/is", $content, $match);
  213. $match = $this->preg_match_all("includes+(.* ?)", $content);
  214. if(!isset($match[1]) || !is_array($match[1])) return $content;
  215. foreach($match[1] as $match_key => ; $match_value) {
  216. $a = preg_split("/s+/is", $match_value);
  217. $new_tag = array();
  218. // 分析元素
  219. foreach($a as $t) {
  220. $b = explode('=', $t);
  221. if(in_array($b[0], $this->tag_include)) {
  222. if(!empty($b[1])) {
  223. $new_tag[$b [0]] = str_replace(""", "", $b[1]);
  224. } else {
  225. core::show_error('模板路径不存在!');
  226. }
  227. }
  228. }
  229. extract( $new_tag);
  230. //模板文件
  231. foreach($this->conf['view_path'] as $v){
  232. $conf_view_tpl = $v.$file;//模板文件
  233. if(is_file($ conf_view_tpl)) {
  234. $c = $this->read_file($conf_view_tpl);
  235. $inc_file = str_replace($this->_tpl_suffix, '', Basename($file));
  236. $this-> ;view_path_param = dirname($file).'/';
  237. $compile_dirpath = $this->check_temp_compile();
  238. $include_file = $this->template_replace($c, $compile_dirpath, $inc_file);//解析
  239. Break;
  240. } else {
  241. core::show_error('模板文件不存在,请仔细检查文件:'. $conf_view_tpl);
  242. }
  243. }
  244. $content = str_replace($match[0][$match_key], '', $content);
  245. }
  246. return $content;
  247. }
  248. /**
  249. * foreach を解析します
  250. * 使用方法
  251. * @param $content template content
  252. * @return html 解析されたコンテンツ
  253. */
  254. private function parse_foreach($content) {
  255. if(empty($content)) return false;
  256. //preg_match_all("/" .$this->template_tag_left."foreachs+(.*?)".$this->template_tag_right."/is", $content, $match);
  257. $match = $this->preg_match_all("foreachs+( .*?)", $content);
  258. if(!isset($match[1]) || !is_array($match[1])) return $content;
  259. foreach($match[1] as $match_key => $value) {
  260. $split = preg_split("/s+/is", $value);
  261. $split = array_filter($split);
  262. $new_tag = array();
  263. foreach($split as $v) {
  264. $a =explode("=", $v);
  265. if(in_array($a[0], $this->tag_foreach)) {///此处过滤标签不存在过滤
  266. $new_tag [$a[0]] = $a[1];
  267. }
  268. }
  269. $key = '';
  270. extract($new_tag);
  271. $key = ($key) ? '$'.$key.' =>' : '' ;
  272. $s = '';
  273. $content = $this-> ;str_replace($match[0][$match_key], $s, $content);
  274. }
  275. return $content;
  276. }
  277. /**
  278. * 一致文字列の終わり
  279. */
  280. プライベート関数 parse_comm($content) {
  281. $search = array(
  282. "/".$this->template_tag_left."/foreach".$this->template_tag_right."/is",
  283. "/".$this->template_tag_left."/if ".$this->template_tag_right."/is",
  284. "/".$this->template_tag_left."else".$this->template_tag_right."/is",
  285. );
  286. $replace = array(
  287. "",
  288. "",
  289. ""
  290. );
  291. $content = preg_replace($ search、$replace、$content);
  292. return $content;
  293. }
  294. /**
  295. * コンパイルディレクトリを確認し、作成されていない場合は再帰的にディレクトリを作成します
  296. * @param string $path ファイルのフルパス
  297. * @return テンプレートの内容
  298. */
  299. プライベート関数 check_temp_compile() {
  300. //$paht = $this->template_c.
  301. $tpl_path = ($this->view_path_param) ? $this->view_path_param : $this->get_tpl_path() ;
  302. $all_tpl_apth = $this->template_c.$tpl_path;
  303. if(!is_dir($all_tpl_apth)) {
  304. $this->create_dir( $tpl_path);
  305. }
  306. return $all_tpl_apth;
  307. }
  308. /**
  309. * ファイルを読み取ります
  310. * @param string $path ファイルのフルパス
  311. * @return テンプレートの内容
  312. */
  313. プライベート関数 read_file($path) {
  314. //$this->check_file_limits($path, 'r');
  315. if(($r = @fopen($path, 'r')) === false) {
  316. core::show_error('模版文件没有读取または执行权限,请检查!');
  317. }
  318. $content = fread($r, filesize($path));
  319. fclose($r);
  320. return $content;
  321. }
  322. /**
  323. * ファイルの書き込み
  324. * @param string $filename ファイル名
  325. * @param string $content テンプレートのコンテンツ
  326. * @return ファイル名
  327. */
  328. プライベート関数compile_file($filename, $content, $dir) {
  329. if(empty($filename)) core::show_error("{$filename} 作成に失敗しました");
  330. $content = $this->body_content($content);//对文件内容操作
  331. //echo '开始编译了=====';
  332. $f = $dir.$filename.$this->tpl_compile_suffix;
  333. //$this->check_file_limits($f, 'w') ;
  334. if(($fp = @fopen($f, 'wb')) === false) {
  335. core::show_error($f.'
    编译文件失败,请检查文件权限。 ');
  336. }
  337. //开启flock
  338. flock($fp, LOCK_EX + LOCK_NB);
  339. fwrite($fp, $content, strlen($content));
  340. flock($fp, LOCK_UN + LOCK_NB);
  341. fclose ($fp);
  342. return $f;
  343. }
  344. /**
  345. * ファイルのパーミッションをチェックする機能は一時的に廃止されます
  346. * @param [$path] [path]
  347. * @param [status] [w=write, r=read]
  348. */
  349. public function check_file_limits($path , $status = 'rw') {
  350. clearstatcache();
  351. if(!is_writable( $path) && $status == 'w') {
  352. core::show_error("{$path}
    没有書入权限,请检查。");
  353. } elseif(!is_readable($path) ) && $status == 'r') {
  354. core::show_error("{$path}
    没有读取权限,请检查。");
  355. } elseif($status == 'rw' ) {//書き込みと読み取りをチェック
  356. if(!is_writable($path) || !is_readable($path)) {
  357. core::show_error("{$path}
    無し写入または读取权制限,请检查");
  358. }
  359. }
  360. }
  361. /* *
  362. * コンパイルされたテンプレートの最初の行を読み取り、配列に解析します
  363. * @param string $filepath ファイルパス
  364. * @param number $line 行数
  365. * @return は指定された行数の文字列を返します
  366. */
  367. /*
  368. プライベート関数 get_compile_header($filepath, $line = 0) {
  369. if(($file_arr = @file($filepath)) === false) {
  370. core::show_error( $filepath.'
    读取文件失败,请检查文件权限!');
  371. }
  372. return $file_arr[0];
  373. }
  374. */
  375. /**
  376. * ヘッダーコメントの分析日
  377. * @param string $cotnent コンパイルされたファイルのヘッダーの最初の行
  378. * @return 最後の日付を返します
  379. */
  380. /*
  381. プライベート関数 get_compile_header_comment($content) {
  382. preg_match("//*(.* ?)*//", $content, $match);
  383. if(!isset($match[1]) || empty($match[1])) core::show_error('コンパイル エラー!');
  384. $arr =explode('|', $match[1]);
  385. $arr_date =explode('##', $arr[0]);
  386. return $arr_date[1];
  387. }
  388. */
  389. / **
  390. * テンプレートのフルパスを取得し、既存のファイルを返します
  391. * @param string $filename ファイル名
  392. * @param string $view_path テンプレートのパス
  393. * @return
  394. */
  395. private function get_tpl($filename, $view_path) {
  396. empty($filename) && $filename = $this->tpl_name;
  397. //テンプレート パスをトラバースします
  398. foreach($this- > ;conf['view_path'] as $path) {
  399. if($view_path) {//tpl とディレクトリから直接ファイルを検索します
  400. $tpl_path = $path.$view_path;
  401. $view_file_path = $tpl_path.$filename.$ this ->tpl_suffix;
  402. } else {//ディレクトリ、コントローラー、メソッドに基づいてファイルの検索を開始します
  403. $view_file_path = ($tpl_path = $this->get_tpl_path($path)) $tpl_path.$filename.$ this- >_tpl_suffix : exit(0);
  404. }
  405. if(is_file($view_file_path)) {
  406. //テンプレートパスとテンプレート名をポインタに転送
  407. $this->template_path = $tpl_path;//
  408. $this- >template_name = $filename.$this->_tpl_suffix;
  409. return true;
  410. } else {
  411. core::show_error($filename.$this->_tpl_suffix.'テンプレートが存在しません');
  412. }
  413. }
  414. }
  415. /**
  416. * テンプレートのパスを取得します
  417. * @param string $path ホームディレクトリ
  418. * @return URL D と M の結合パス
  419. */
  420. プライベート関数 get_tpl_path($path = '') {
  421. core::get_directory_name() && $path_arr[0] = core::get_directory_name();
  422. core ::get_controller_name( ) && $path_arr[1] = core::get_controller_name();
  423. (is_array($path_arr)) $newpath = implode('/', $path_arr) : core::show_error('取得に失敗しましたテンプレート パス!') ;
  424. return $path.$newpath.'/';
  425. }
  426. /**
  427. * ディレクトリを作成します
  428. * @param string $path ディレクトリ
  429. * @return
  430. */
  431. プライベート関数 create_dir($path, $mode = 0777){
  432. if(is_dir( $path)) return false;
  433. $dir_arr =explode('/', $path);
  434. $dir_arr = array_filter($dir_arr);
  435. $allpath = '';
  436. $newdir = $this->template_c ;
  437. foreach( $dir_arr as $dir) {
  438. $allpath = $newdir.'/'.$dir;
  439. if(!is_dir($allpath)) {
  440. $newdir = $allpath;
  441. if(! @mkdir($allpath , $mode)) {
  442. core::show_error( $allpath.'
    ディレクトリの作成に失敗しました。書き込み権限があるかどうかを確認してください。 ');
  443. }
  444. chmod($allpath, $mode);
  445. } else {
  446. $newdir = $allpath;
  447. }
  448. }
  449. return true;
  450. }
  451. public function __destruct(){
  452. $this-> vars = null;
  453. $this->view_path_param = null;
  454. }
  455. };
コードをコピー


声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
PHPの現在のステータス:Web開発動向を見てくださいPHPの現在のステータス:Web開発動向を見てくださいApr 13, 2025 am 12:20 AM

PHPは、現代のWeb開発、特にコンテンツ管理とeコマースプラットフォームで依然として重要です。 1)PHPには、LaravelやSymfonyなどの豊富なエコシステムと強力なフレームワークサポートがあります。 2)パフォーマンスの最適化は、Opcacheとnginxを通じて達成できます。 3)PHP8.0は、パフォーマンスを改善するためにJITコンパイラを導入します。 4)クラウドネイティブアプリケーションは、DockerおよびKubernetesを介して展開され、柔軟性とスケーラビリティを向上させます。

PHP対その他の言語:比較PHP対その他の言語:比較Apr 13, 2025 am 12:19 AM

PHPは、特に迅速な開発や動的なコンテンツの処理に適していますが、データサイエンスとエンタープライズレベルのアプリケーションには良くありません。 Pythonと比較して、PHPはWeb開発においてより多くの利点がありますが、データサイエンスの分野ではPythonほど良くありません。 Javaと比較して、PHPはエンタープライズレベルのアプリケーションでより悪化しますが、Web開発により柔軟性があります。 JavaScriptと比較して、PHPはバックエンド開発により簡潔ですが、フロントエンド開発のJavaScriptほど良くありません。

PHP対Python:コア機能と機能PHP対Python:コア機能と機能Apr 13, 2025 am 12:16 AM

PHPとPythonにはそれぞれ独自の利点があり、さまざまなシナリオに適しています。 1.PHPはWeb開発に適しており、組み込みのWebサーバーとRich Functionライブラリを提供します。 2。Pythonは、簡潔な構文と強力な標準ライブラリを備えたデータサイエンスと機械学習に適しています。選択するときは、プロジェクトの要件に基づいて決定する必要があります。

PHP:Web開発の重要な言語PHP:Web開発の重要な言語Apr 13, 2025 am 12:08 AM

PHPは、サーバー側で広く使用されているスクリプト言語で、特にWeb開発に適しています。 1.PHPは、HTMLを埋め込み、HTTP要求と応答を処理し、さまざまなデータベースをサポートできます。 2.PHPは、ダイナミックWebコンテンツ、プロセスフォームデータ、アクセスデータベースなどを生成するために使用され、強力なコミュニティサポートとオープンソースリソースを備えています。 3。PHPは解釈された言語であり、実行プロセスには語彙分析、文法分析、編集、実行が含まれます。 4.PHPは、ユーザー登録システムなどの高度なアプリケーションについてMySQLと組み合わせることができます。 5。PHPをデバッグするときは、error_reporting()やvar_dump()などの関数を使用できます。 6. PHPコードを最適化して、キャッシュメカニズムを使用し、データベースクエリを最適化し、組み込み関数を使用します。 7

PHP:多くのウェブサイトの基礎PHP:多くのウェブサイトの基礎Apr 13, 2025 am 12:07 AM

PHPが多くのWebサイトよりも優先テクノロジースタックである理由には、その使いやすさ、強力なコミュニティサポート、広範な使用が含まれます。 1)初心者に適した学習と使用が簡単です。 2)巨大な開発者コミュニティと豊富なリソースを持っています。 3)WordPress、Drupal、その他のプラットフォームで広く使用されています。 4)Webサーバーとしっかりと統合して、開発の展開を簡素化します。

誇大広告を超えて:今日のPHPの役割の評価誇大広告を超えて:今日のPHPの役割の評価Apr 12, 2025 am 12:17 AM

PHPは、特にWeb開発の分野で、最新のプログラミングで強力で広く使用されているツールのままです。 1)PHPは使いやすく、データベースとシームレスに統合されており、多くの開発者にとって最初の選択肢です。 2)動的コンテンツ生成とオブジェクト指向プログラミングをサポートし、Webサイトを迅速に作成および保守するのに適しています。 3)PHPのパフォーマンスは、データベースクエリをキャッシュおよび最適化することで改善でき、その広範なコミュニティと豊富なエコシステムにより、今日のテクノロジースタックでは依然として重要になります。

PHPの弱い参照は何ですか、そしていつ有用ですか?PHPの弱い参照は何ですか、そしていつ有用ですか?Apr 12, 2025 am 12:13 AM

PHPでは、弱い参照クラスを通じて弱い参照が実装され、ガベージコレクターがオブジェクトの回収を妨げません。弱い参照は、キャッシュシステムやイベントリスナーなどのシナリオに適しています。オブジェクトの生存を保証することはできず、ごみ収集が遅れる可能性があることに注意する必要があります。

PHPで__invoke Magicメソッドを説明してください。PHPで__invoke Magicメソッドを説明してください。Apr 12, 2025 am 12:07 AM

\ _ \ _ Invokeメソッドを使用すると、オブジェクトを関数のように呼び出すことができます。 1。オブジェクトを呼び出すことができるように\ _ \ _呼び出しメソッドを定義します。 2。$ obj(...)構文を使用すると、PHPは\ _ \ _ Invokeメソッドを実行します。 3。ロギングや計算機、コードの柔軟性の向上、読みやすさなどのシナリオに適しています。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

Dreamweaver Mac版

Dreamweaver Mac版

ビジュアル Web 開発ツール

WebStorm Mac版

WebStorm Mac版

便利なJavaScript開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

mPDF

mPDF

mPDF は、UTF-8 でエンコードされた HTML から PDF ファイルを生成できる PHP ライブラリです。オリジナルの作者である Ian Back は、Web サイトから「オンザフライ」で PDF ファイルを出力し、さまざまな言語を処理するために mPDF を作成しました。 HTML2FPDF などのオリジナルのスクリプトよりも遅く、Unicode フォントを使用すると生成されるファイルが大きくなりますが、CSS スタイルなどをサポートし、多くの機能強化が施されています。 RTL (アラビア語とヘブライ語) や CJK (中国語、日本語、韓国語) を含むほぼすべての言語をサポートします。ネストされたブロックレベル要素 (P、DIV など) をサポートします。