Skip to content

Commit 27e7de2

Browse files
authored
Merge pull request #5854 from kenjis/fix-docs-replace-echo-with-return
docs: replace `echo` with `return`
2 parents fcfcdf7 + e0569f6 commit 27e7de2

40 files changed

Lines changed: 59 additions & 56 deletions

File tree

user_guide_src/source/cli/cli/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class Tools extends Controller
88
{
99
public function message($to = 'World')
1010
{
11-
echo "Hello {$to}!" . PHP_EOL;
11+
return "Hello {$to}!" . PHP_EOL;
1212
}
1313
}

user_guide_src/source/incoming/controllers/008.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class Helloworld extends BaseController
66
{
77
public function index()
88
{
9-
echo 'Hello World!';
9+
return 'Hello World!';
1010
}
1111
}

user_guide_src/source/incoming/controllers/013.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ class Helloworld extends BaseController
66
{
77
public function index()
88
{
9-
echo 'Hello World!';
9+
return 'Hello World!';
1010
}
1111

1212
public function comment()
1313
{
14-
echo 'I am not flat!';
14+
return 'I am not flat!';
1515
}
1616
}

user_guide_src/source/incoming/controllers/014.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Products extends BaseController
66
{
77
public function shoes($sandals, $id)
88
{
9-
echo $sandals;
10-
echo $id;
9+
return $sandals
10+
. $id;
1111
}
1212
}

user_guide_src/source/installation/upgrade_controllers/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class Helloworld extends BaseController
66
{
77
public function index($name)
88
{
9-
echo 'Hello ' . esc($name) . '!';
9+
return 'Hello ' . esc($name) . '!';
1010
}
1111
}

user_guide_src/source/installation/upgrade_file_upload/001.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Upload extends BaseController
66
{
77
public function index()
88
{
9-
echo view('upload_form', ['error' => ' ']);
9+
return view('upload_form', ['error' => ' ']);
1010
}
1111

1212
public function do_upload()
@@ -20,11 +20,10 @@ public function do_upload()
2020
$file = $this->request->getFile('userfile');
2121

2222
if (! $path = $file->store()) {
23-
echo view('upload_form', ['error' => 'upload failed']);
24-
} else {
25-
$data = ['upload_file_path' => $path];
26-
27-
echo view('upload_success', $data);
23+
return view('upload_form', ['error' => 'upload failed']);
2824
}
25+
$data = ['upload_file_path' => $path];
26+
27+
return view('upload_success', $data);
2928
}
3029
}

user_guide_src/source/installation/upgrade_pagination/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
'pager' => $model->pager,
88
];
99

10-
echo view('users/index', $data);
10+
return view('users/index', $data);

user_guide_src/source/installation/upgrade_view_parser.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ What has been changed
1919
Upgrade Guide
2020
=============
2121
1. Wherever you use the View Parser Library replace ``$this->load->library('parser');`` with ``$parser = service('parser');``.
22-
2. You have to change the render part in your controller from ``$this->parser->parse('blog_template', $data);`` to ``echo $parser->setData($data)->render('blog_template');``.
22+
2. You have to change the render part in your controller from ``$this->parser->parse('blog_template', $data);`` to ``return $parser->setData($data)->render('blog_template');``.
2323

2424
Code Example
2525
============

user_guide_src/source/installation/upgrade_view_parser/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
'blog_heading' => 'My Blog Heading',
88
];
99

10-
echo $parser->setData($data)->render('blog_template');
10+
return $parser->setData($data)->render('blog_template');

user_guide_src/source/installation/upgrade_views.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ What has been changed
1515
=====================
1616

1717
- Your views look much like before, but they are invoked differently ... instead of CI3's
18-
``$this->load->view(x);``, you can use ``echo view(x);``.
18+
``$this->load->view(x);``, you can use ``return view(x);``.
1919
- CI4 supports *View Cells* to build your response in pieces, and *View Layouts* for page layout.
2020
- The template parser is still there, and substantially enhanced.
2121

@@ -24,7 +24,7 @@ Upgrade Guide
2424

2525
1. First, move all views to the folder **app/Views**
2626
2. Change the loading syntax of views in every script where you load views:
27-
- from ``$this->load->view('directory_name/file_name')`` to ``echo view('directory_name/file_name');``
27+
- from ``$this->load->view('directory_name/file_name')`` to ``return view('directory_name/file_name');``
2828
- from ``$content = $this->load->view('file', $data, TRUE);`` to ``$content = view('file', $data);``
2929
3. (optional) You can change the echo syntax in views from ``<?php echo $title; ?>`` to ``<?= $title ?>``
3030

0 commit comments

Comments
 (0)