8000 bug #4444 fix elseif statement (MightyBranch) · symfony/symfony-docs@85bf906 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85bf906

Browse files
committed
bug #4444 fix elseif statement (MightyBranch)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #4444). Discussion ---------- fix elseif statement | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | -- In this example of the book, the elseif block always evaluates to FALSE since $_SERVER['REQUEST_URI'] includes the query string, therefore if $uri equals to '/index.php/show' then $_GET['id'] is never set, and the list_action() is never executed. Here I propose a fix by cleaning the query string from the URI before assigning it to $uri, using the built-in function parse_url(). Commits ------- ab10529 fix elseif statement
2 parents 3969fd6 + ab10529 commit 85bf906

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

book/from_flat_php_to_symfony2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ on the requested URI:
367367
require_once 'controllers.php';
368368

369369
// route the request internally
370-
$uri = $_SERVER['REQUEST_URI'];
370+
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
371371
if ('/index.php' == $uri) {
372372
list_action();
373373
} elseif ('/index.php/show' == $uri && isset($_GET['id'])) {

0 commit comments

Comments
 (0)
0