@@ -18,7 +18,6 @@ Even if the "application" we wrote in the previous chapter was simple enough,
1818it suffers from a few problems::
1919
2020 // framework/index.php
21-
2221 $input = $_GET['name'];
2322
2423 printf('Hello %s', $input);
@@ -27,7 +26,6 @@ First, if the ``name`` query parameter is not defined in the URL query string,
2726you will get a PHP warning; so let's fix it::
2827
2928 // framework/index.php
30-
3129 $input = isset($_GET['name']) ? $_GET['name'] : 'World';
3230
3331 printf('Hello %s', $input);
@@ -60,7 +58,6 @@ snippet of PHP code is not natural and feels ugly. Here is a tentative PHPUnit
6058unit test for the above code::
6159
6260 // framework/test.php
63-
6461 class IndexTest extends \PHPUnit_Framework_TestCase
6562 {
6663 public function testHello()
@@ -147,7 +144,6 @@ Now, let's rewrite our application by using the ``Request`` and the
147144``Response `` classes::
148145
149146 // framework/index.php
150-
151147 require_once __DIR__.'/vendor/autoload.php';
152148
153149 use Symfony\Component\HttpFoundation\Request;
@@ -227,7 +223,7 @@ With the ``Response`` class, you can easily tweak the response::
227223
228224.. tip ::
229225
230- To debug a Response , cast it to a string; it will return the HTTP
226+ To debug a response , cast it to a string; it will return the HTTP
231227 representation of the response (headers and content).
232228
233229Last but not the least, these classes, like every other class in the Symfony
@@ -239,7 +235,7 @@ framework?
239235
240236Even something as simple as getting the client IP address can be insecure::
241237
242- if ($myIp == $_SERVER['REMOTE_ADDR']) {
238+ if ($myIp === $_SERVER['REMOTE_ADDR']) {
243239 // the client is a known one, so give it some more privilege
244240 }
245241
@@ -248,7 +244,7 @@ production servers; at this point, you will have to change your code to make
248244it work on both your development machine (where you don't have a proxy) and
249245your servers::
250246
251- if ($myIp == $_SERVER['HTTP_X_FORWARDED_FOR'] || $myIp == $_SERVER['REMOTE_ADDR']) {
247+ if ($myIp === $_SERVER['HTTP_X_FORWARDED_FOR'] || $myIp = == $_SERVER['REMOTE_ADDR']) {
252248 // the client is a known one, so give it some more privilege
253249 }
254250
@@ -258,7 +254,7 @@ chained proxies)::
258254
259255 $request = Request::createFromGlobals();
260256
261- if ($myIp == $request->getClientIp()) {
257+ if ($myIp === $request->getClientIp()) {
262258 // the client is a known one, so give it some more privilege
263259 }
264260
@@ -271,7 +267,7 @@ explicitly trust your reverse proxies by calling ``setTrustedProxies()``::
271267
272268 Request::setTrustedProxies(array('10.0.0.1'));
273269
274- if ($myIp == $request->getClientIp(true)) {
270+ if ($myIp === $request->getClientIp(true)) {
275271 // the client is a known one, so give it some more privilege
276272 }
277273
0 commit comments