Skip to content

Commit

Permalink
bug #4444 fix elseif statement (MightyBranch)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weaverryan committed Nov 20, 2014
2 parents 3969fd6 + ab10529 commit 85bf906
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion book/from_flat_php_to_symfony2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ on the requested URI:
require_once 'controllers.php';

// route the request internally
$uri = $_SERVER['REQUEST_URI'];
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
if ('/index.php' == $uri) {
list_action();
} elseif ('/index.php/show' == $uri && isset($_GET['id'])) {
Expand Down

0 comments on commit 85bf906

Please sign in to comment.