{"id":80,"date":"2025-02-27T03:31:47","date_gmt":"2025-02-27T00:01:47","guid":{"rendered":"https:\/\/techport.ir\/?p=80"},"modified":"2025-02-27T03:31:47","modified_gmt":"2025-02-27T00:01:47","slug":"php-generator-%da%86%db%8c%d8%b3%d8%aa%d8%9f","status":"publish","type":"post","link":"https:\/\/techport.ir\/?p=80","title":{"rendered":"php generator \u0686\u06cc\u0633\u062a\u061f"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u0645\u0646\u0628\u0639: chatgpt<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 PHP\u060c \u06cc\u06a9 <strong>Generator<\/strong> \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u06a9\u0647 \u0628\u0647 \u062c\u0627\u06cc \u0628\u0627\u0632\u06af\u0634\u062a \u062a\u0645\u0627\u0645\u06cc \u0645\u0642\u0627\u062f\u06cc\u0631 \u06cc\u06a9\u062c\u0627 \u0627\u0632 \u06cc\u06a9 \u062a\u0627\u0628\u0639\u060c \u0647\u0631 \u0645\u0642\u062f\u0627\u0631 \u0631\u0627 \u062f\u0631 \u0647\u0631 \u0628\u0627\u0631 \u0627\u062c\u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u062a\u062f\u0631\u06cc\u062c\u06cc \u062a\u0648\u0644\u06cc\u062f \u06a9\u0646\u06cc\u062f. \u0627\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u0628\u0647 \u0635\u0631\u0641\u0647\u200c\u062c\u0648\u06cc\u06cc \u062f\u0631 \u062d\u0627\u0641\u0638\u0647 \u0648 \u067e\u0631\u062f\u0627\u0632\u0634 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af \u06a9\u0645\u06a9 \u0645\u06cc\u200c\u06a9\u0646\u062f\u060c \u0628\u0647\u200c\u0648\u06cc\u0698\u0647 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u0627 \u067e\u06cc\u0645\u0627\u06cc\u0634 \u0645\u062c\u0645\u0648\u0639\u0647\u200c\u0627\u06cc \u0627\u0632 \u062f\u0627\u062f\u0647\u200c\u0647\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u062a\u062f\u0631\u06cc\u062c\u06cc \u0628\u0627\u0634\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Generators \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u06a9\u0644\u0645\u0647 \u06a9\u0644\u06cc\u062f\u06cc <code>yield<\/code> \u062a\u0639\u0631\u06cc\u0641 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f. \u0647\u0631 \u0628\u0627\u0631 \u06a9\u0647 \u062a\u0627\u0628\u0639 generator \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u062a\u0627 \u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0628\u0647 <code>yield<\/code> \u0628\u0631\u062e\u0648\u0631\u062f \u06a9\u0646\u062f \u0627\u062c\u0631\u0627 \u0645\u06cc\u200c\u0634\u0648\u062f\u060c \u0645\u0642\u062f\u0627\u0631 \u0631\u0627 \u0628\u0631\u0645\u06cc\u200c\u06af\u0631\u062f\u0627\u0646\u062f \u0648 \u0633\u067e\u0633 \u0648\u0636\u0639\u06cc\u062a \u062e\u0648\u062f \u0631\u0627 \u062d\u0641\u0638 \u0645\u06cc\u200c\u06a9\u0646\u062f \u062a\u0627 \u062f\u0631 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc \u0628\u0639\u062f\u06cc \u0627\u0632 \u0647\u0645\u0627\u0646 \u0646\u0642\u0637\u0647 \u0627\u062f\u0627\u0645\u0647 \u06cc\u0627\u0628\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0645\u062b\u0627\u0644 \u0633\u0627\u062f\u0647:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function simpleGenerator() {\n    yield 1;\n    yield 2;\n    yield 3;\n}\n\n$gen = simpleGenerator();\nforeach ($gen as $value) {\n    echo $value; \/\/ \u062e\u0631\u0648\u062c\u06cc: 1 2 3\n}\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">simpleGenerator<\/span><span style=\"color: #F8F8F2\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">yield<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">1<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">yield<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">2<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">yield<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #BD93F9\">3<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">$gen <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">simpleGenerator<\/span><span style=\"color: #F8F8F2\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">foreach<\/span><span style=\"color: #F8F8F2\"> ($gen <\/span><span style=\"color: #FF79C6\">as<\/span><span style=\"color: #F8F8F2\"> $value) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #8BE9FD\">echo<\/span><span style=\"color: #F8F8F2\"> $value; <\/span><span style=\"color: #6272A4\">\/\/ \u062e\u0631\u0648\u062c\u06cc: 1 2 3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u06a9\u0627\u0631\u0628\u0631\u062f:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u0635\u0631\u0641\u0647\u200c\u062c\u0648\u06cc\u06cc \u062f\u0631 \u062d\u0627\u0641\u0638\u0647:<\/strong> \u0628\u0647 \u062c\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u06cc\u06a9 \u0622\u0631\u0627\u06cc\u0647 \u0628\u0632\u0631\u06af \u0627\u0632 \u0645\u0642\u0627\u062f\u06cc\u0631 \u0631\u0627 \u0628\u0647 \u0637\u0648\u0631 \u06a9\u0627\u0645\u0644 \u062f\u0631 \u062d\u0627\u0641\u0638\u0647 \u0646\u06af\u0647 \u062f\u0627\u0631\u062f\u060c \u0628\u0647 \u062a\u062f\u0631\u06cc\u062c \u0645\u0642\u062f\u0627\u0631 \u062a\u0648\u0644\u06cc\u062f \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u067e\u0631\u062f\u0627\u0632\u0634 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af:<\/strong> \u062f\u0631 \u0645\u0648\u0627\u0642\u0639\u06cc \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u0645\u062c\u0645\u0648\u0639\u0647 \u0628\u0632\u0631\u06af\u06cc \u0627\u0632 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u0633\u062a (\u0645\u0627\u0646\u0646\u062f \u062e\u0648\u0627\u0646\u062f\u0646 \u062e\u0637\u0648\u0637 \u06cc\u06a9 \u0641\u0627\u06cc\u0644)\u060c generator \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u062f\u0627\u062f\u0647\u200c\u0647\u0627 \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u0642\u0637\u0639\u0647\u200c\u0642\u0637\u0639\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u06a9\u0646\u06cc\u062f.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0645\u062b\u0627\u0644 \u06a9\u0627\u0631\u0628\u0631\u062f\u06cc (\u062e\u0648\u0627\u0646\u062f\u0646 \u0641\u0627\u06cc\u0644):<\/strong><\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function readFileLines($file) {\n    $handle = fopen($file, 'r');\n    while (!feof($handle)) {\n        yield fgets($handle);\n    }\n    fclose($handle);\n}\n\nforeach (readFileLines('largefile.txt') as $line) {\n    echo $line;\n}\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #FF79C6\">function<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #50FA7B\">readFileLines<\/span><span style=\"color: #F8F8F2\">($file) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    $handle <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">fopen<\/span><span style=\"color: #F8F8F2\">($file,<\/span><span style=\"color: #50FA7B\"> <\/span><span style=\"color: #E9F284\">&#39;<\/span><span style=\"color: #F1FA8C\">r<\/span><span style=\"color: #E9F284\">&#39;<\/span><span style=\"color: #F8F8F2\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #FF79C6\">while<\/span><span style=\"color: #F8F8F2\"> (<\/span><span style=\"color: #FF79C6\">!<\/span><span style=\"color: #8BE9FD\">feof<\/span><span style=\"color: #F8F8F2\">($handle)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">        <\/span><span style=\"color: #FF79C6\">yield<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #8BE9FD\">fgets<\/span><span style=\"color: #F8F8F2\">($handle);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #8BE9FD\">fclose<\/span><span style=\"color: #F8F8F2\">($handle);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">foreach<\/span><span style=\"color: #F8F8F2\"> (<\/span><span style=\"color: #50FA7B\">readFileLines<\/span><span style=\"color: #F8F8F2\">(<\/span><span style=\"color: #E9F284\">&#39;<\/span><span style=\"color: #F1FA8C\">largefile.txt<\/span><span style=\"color: #E9F284\">&#39;<\/span><span style=\"color: #F8F8F2\">) <\/span><span style=\"color: #FF79C6\">as<\/span><span style=\"color: #F8F8F2\"> $line) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #8BE9FD\">echo<\/span><span style=\"color: #F8F8F2\"> $line;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0646\u062a\u06cc\u062c\u0647:<\/strong> \u0627\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u0628\u0647 \u0634\u0645\u0627 \u0627\u062c\u0627\u0632\u0647 \u0645\u06cc\u200c\u062f\u0647\u062f \u06a9\u0647 \u0628\u062f\u0648\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062d\u0627\u0641\u0638\u0647 \u0627\u0636\u0627\u0641\u06cc\u060c \u0641\u0627\u06cc\u0644\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u062e\u0637 \u0628\u0647 \u062e\u0637 \u0628\u062e\u0648\u0627\u0646\u06cc\u062f \u0648 \u067e\u0631\u062f\u0627\u0632\u0634 \u06a9\u0646\u06cc\u062f.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u062f\u0631 \u0644\u0627\u0631\u0627\u0648\u0644 \u06a9\u062c\u0627 \u0627\u0632 php generator \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a\u061f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 <strong>\u0644\u0627\u0631\u0627\u0648\u0644<\/strong>\u060c \u0627\u0632 PHP <strong>Generators<\/strong> \u062f\u0631 \u0642\u0633\u0645\u062a\u200c\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0641\u0631\u06cc\u0645\u200c\u0648\u0631\u06a9 \u0628\u0631\u0627\u06cc \u0628\u0647\u0628\u0648\u062f \u06a9\u0627\u0631\u0627\u06cc\u06cc \u0648 \u0645\u062f\u06cc\u0631\u06cc\u062a \u062d\u0627\u0641\u0638\u0647 \u0628\u0647\u200c\u062e\u0635\u0648\u0635 \u062f\u0631 \u06a9\u0627\u0631 \u0628\u0627 \u0645\u062c\u0645\u0648\u0639\u0647\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af \u062f\u0627\u062f\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a. \u06cc\u06a9\u06cc \u0627\u0632 \u0645\u0647\u0645\u200c\u062a\u0631\u06cc\u0646 \u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647\u200c\u06cc generator \u062f\u0631 \u0644\u0627\u0631\u0627\u0648\u0644 \u0645\u0631\u0628\u0648\u0637 \u0628\u0647 <strong>Eloquent<\/strong> \u0648 <strong>Cursor<\/strong> \u0627\u0633\u062a.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Eloquent Cursor:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0647\u0646\u06af\u0627\u0645\u06cc \u06a9\u0647 \u0634\u0645\u0627 \u0646\u06cc\u0627\u0632 \u062f\u0627\u0631\u06cc\u062f \u0631\u06a9\u0648\u0631\u062f\u0647\u0627\u06cc \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u062f\u06cc\u062a\u0627\u0628\u06cc\u0633 \u0631\u0627 \u067e\u0631\u062f\u0627\u0632\u0634 \u06a9\u0646\u06cc\u062f \u0648\u0644\u06cc \u0646\u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u062f \u062a\u0645\u0627\u0645 \u0622\u0646\u0647\u0627 \u0631\u0627 \u0628\u0647 \u06cc\u06a9\u0628\u0627\u0631\u0647 \u062f\u0631 \u062d\u0627\u0641\u0638\u0647 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc \u06a9\u0646\u06cc\u062f\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u06cc\u062f \u0627\u0632 \u0645\u062a\u062f <code>cursor<\/code> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f. \u0627\u06cc\u0646 \u0645\u062a\u062f \u0627\u0632 generator \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u062f \u062a\u0627 \u0631\u06a9\u0648\u0631\u062f\u0647\u0627 \u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u062a\u062f\u0631\u06cc\u062c\u06cc \u0648 \u0628\u0647\u06cc\u0646\u0647\u200c\u0633\u0627\u0632\u06cc \u0634\u062f\u0647 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc \u06a9\u0646\u062f.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"$users = \\App\\Models\\User::cursor();\n\nforeach ($users as $user) {\n    echo $user-&gt;name;\n}\" style=\"color:#F8F8F2;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dracula\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">$users <\/span><span style=\"color: #FF79C6\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #FF79C6; font-style: italic\">\\<\/span><span style=\"color: #8BE9FD; font-style: italic\">App<\/span><span style=\"color: #FF79C6; font-style: italic\">\\<\/span><span style=\"color: #8BE9FD; font-style: italic\">Models<\/span><span style=\"color: #FF79C6; font-style: italic\">\\<\/span><span style=\"color: #8BE9FD; font-style: italic\">User<\/span><span style=\"color: #FF79C6\">::<\/span><span style=\"color: #50FA7B\">cursor<\/span><span style=\"color: #F8F8F2\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #FF79C6\">foreach<\/span><span style=\"color: #F8F8F2\"> ($users <\/span><span style=\"color: #FF79C6\">as<\/span><span style=\"color: #F8F8F2\"> $user) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">    <\/span><span style=\"color: #8BE9FD\">echo<\/span><span style=\"color: #F8F8F2\"> $user<\/span><span style=\"color: #FF79C6\">-&gt;<\/span><span style=\"color: #F8F8F2\">name;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 <code>cursor()<\/code> \u0628\u0647 \u062c\u0627\u06cc \u0627\u06cc\u0646\u06a9\u0647 \u062a\u0645\u0627\u0645 \u06a9\u0627\u0631\u0628\u0631\u0627\u0646 \u0631\u0627 \u0628\u0647 \u06cc\u06a9\u0628\u0627\u0631\u0647 \u0627\u0632 \u062f\u06cc\u062a\u0627\u0628\u06cc\u0633 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc \u06a9\u0646\u062f (\u06a9\u0647 \u0645\u0645\u06a9\u0646 \u0627\u0633\u062a \u0645\u0646\u062c\u0631 \u0628\u0647 \u0645\u0634\u06a9\u0644\u0627\u062a \u062d\u0627\u0641\u0638\u0647 \u0634\u0648\u062f)\u060c \u0627\u0632 generator \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u06a9\u0646\u062f \u062a\u0627 \u0631\u06a9\u0648\u0631\u062f\u0647\u0627 \u0631\u0627 \u06cc\u06a9\u06cc\u200c\u06cc\u06a9\u06cc \u062f\u0631 \u0647\u0631 \u0628\u0627\u0631 \u0641\u0631\u0627\u062e\u0648\u0627\u0646\u06cc <code>yield<\/code> \u06a9\u0646\u062f. \u0627\u06cc\u0646 \u0631\u0648\u0634 \u0628\u0633\u06cc\u0627\u0631 \u06a9\u0627\u0631\u0622\u0645\u062f \u0627\u0633\u062a\u060c \u0628\u0647 \u062e\u0635\u0648\u0635 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u062d\u062c\u0645 \u0628\u0632\u0631\u06af\u06cc \u0627\u0632 \u062f\u0627\u062f\u0647\u200c\u0647\u0627 \u0628\u0627\u06cc\u062f \u067e\u0631\u062f\u0627\u0632\u0634 \u0634\u0648\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0645\u0648\u0627\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u0645\u062f\u06cc\u0631\u06cc\u062a \u06a9\u0627\u0631\u0622\u0645\u062f \u062d\u0627\u0641\u0638\u0647:<\/strong> \u062f\u0631 \u0634\u0631\u0627\u06cc\u0637\u06cc \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u062a\u0639\u062f\u0627\u062f \u0632\u06cc\u0627\u062f\u06cc \u0627\u0632 \u0631\u06a9\u0648\u0631\u062f\u0647\u0627 \u062f\u0627\u0631\u06cc\u062f \u0648 \u0646\u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u062f \u06a9\u0644 \u062f\u0627\u062f\u0647\u200c\u0647\u0627 \u0628\u0647 \u06cc\u06a9\u0628\u0627\u0631\u0647 \u062f\u0631 \u062d\u0627\u0641\u0638\u0647 \u0628\u0627\u0631\u06af\u0630\u0627\u0631\u06cc \u0634\u0648\u0646\u062f.<\/li>\n\n\n\n<li><strong>\u067e\u0631\u062f\u0627\u0632\u0634 \u0631\u06a9\u0648\u0631\u062f\u0647\u0627\u06cc \u062d\u062c\u06cc\u0645:<\/strong> \u0645\u062b\u0644\u0627\u064b \u062f\u0631 \u06cc\u06a9 job \u0637\u0648\u0644\u0627\u0646\u06cc\u200c\u0645\u062f\u062a \u0628\u0631\u0627\u06cc \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u0627 \u0627\u06cc\u062c\u0627\u062f \u06af\u0632\u0627\u0631\u0634\u0627\u062a\u060c \u0645\u06cc\u200c\u062a\u0648\u0627\u0646 \u0627\u0632 <code>cursor()<\/code> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0631\u062f \u062a\u0627 \u0631\u06a9\u0648\u0631\u062f\u0647\u0627 \u0628\u0647\u200c\u0635\u0648\u0631\u062a \u067e\u06cc\u0648\u0633\u062a\u0647 \u0648 \u06a9\u0627\u0631\u0622\u0645\u062f \u062e\u0648\u0627\u0646\u062f\u0647 \u0634\u0648\u0646\u062f.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u0646\u062a\u06cc\u062c\u0647:<\/strong> \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 generator \u062f\u0631 \u0644\u0627\u0631\u0627\u0648\u0644 \u062f\u0631 \u0645\u062a\u062f\u06cc \u0645\u062b\u0644 <code>cursor()<\/code> \u0627\u0645\u06a9\u0627\u0646 \u0645\u062f\u06cc\u0631\u06cc\u062a \u0628\u0647\u06cc\u0646\u0647\u200c\u062a\u0631\u06cc \u0628\u0631\u0627\u06cc \u0645\u062c\u0645\u0648\u0639\u0647\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af \u062f\u0627\u062f\u0647 \u0641\u0631\u0627\u0647\u0645 \u0645\u06cc\u200c\u06a9\u0646\u062f \u0648 \u0627\u0632 \u0645\u0635\u0631\u0641 \u0628\u06cc\u200c\u0631\u0648\u06cc\u0647\u200c\u06cc \u062d\u0627\u0641\u0638\u0647 \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0645\u06cc\u200c\u06a9\u0646\u062f.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0645\u0646\u0628\u0639: chatgpt \u062f\u0631 PHP\u060c \u06cc\u06a9 Generator \u0628\u0647 \u0634\u0645\u0627 \u0627\u0645\u06a9\u0627\u0646 \u0645\u06cc\u200c\u062f\u0647\u062f \u06a9\u0647 \u0628\u0647 \u062c\u0627\u06cc \u0628\u0627\u0632\u06af\u0634\u062a \u062a\u0645\u0627\u0645\u06cc \u0645\u0642\u0627\u062f\u06cc\u0631 \u06cc\u06a9\u062c\u0627 \u0627\u0632 \u06cc\u06a9 \u062a\u0627\u0628\u0639\u060c \u0647\u0631 \u0645\u0642\u062f\u0627\u0631 \u0631\u0627 \u062f\u0631 \u0647\u0631 \u0628\u0627\u0631 \u0627\u062c\u0631\u0627 \u0628\u0647 \u0635\u0648\u0631\u062a \u062a\u062f\u0631\u06cc\u062c\u06cc \u062a\u0648\u0644\u06cc\u062f \u06a9\u0646\u06cc\u062f. \u0627\u06cc\u0646 \u0648\u06cc\u0698\u06af\u06cc \u0628\u0647 \u0635\u0631\u0641\u0647\u200c\u062c\u0648\u06cc\u06cc \u062f\u0631 \u062d\u0627\u0641\u0638\u0647 \u0648 \u067e\u0631\u062f\u0627\u0632\u0634 \u062f\u0627\u062f\u0647\u200c\u0647\u0627\u06cc \u0628\u0632\u0631\u06af \u06a9\u0645\u06a9 \u0645\u06cc\u200c\u06a9\u0646\u062f\u060c \u0628\u0647\u200c\u0648\u06cc\u0698\u0647 \u0632\u0645\u0627\u0646\u06cc \u06a9\u0647 \u0646\u06cc\u0627\u0632 \u0628\u0647 \u067e\u0631\u062f\u0627\u0632\u0634 \u06cc\u0627 \u067e\u06cc\u0645\u0627\u06cc\u0634 \u0645\u062c\u0645\u0648\u0639\u0647\u200c\u0627\u06cc \u0627\u0632 \u062f\u0627\u062f\u0647\u200c\u0647\u0627 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,3],"tags":[5],"class_list":["post-80","post","type-post","status-publish","format-standard","hentry","category-laravel","category-php","tag-source_chatgpt"],"_links":{"self":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/80","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=80"}],"version-history":[{"count":1,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions"}],"predecessor-version":[{"id":81,"href":"https:\/\/techport.ir\/index.php?rest_route=\/wp\/v2\/posts\/80\/revisions\/81"}],"wp:attachment":[{"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=80"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=80"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techport.ir\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=80"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}