flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.61k stars 408 forks source link

Undefined variable: url (8) #249

Closed fatihmert closed 8 years ago

fatihmert commented 8 years ago

Hi guys,

I couldn't define standart php variable with work on just Flightphp.

`$url = array( "HOME_PAGE" => "homepage.html", "ABOUT_US" => "about-us.html" );

Flight::route("/(".$url['HOME_PAGE'].")", function(){`

How can I create and workable standart php variable ? Thank you for interest.

Good works..

tamtamchik commented 8 years ago

@fatihmert your code works OK for me.

<?php

require 'vendor/autoload.php'; // just using Composer to require Flight

$url = array(
  "HOME_PAGE" => "homepage.html",
  "ABOUT_US" => "about-us.html"
);

Flight::route("/(".$url['HOME_PAGE'].")", function(){
  echo 'HOME_PAGE';
});

Flight::route("/(".$url['ABOUT_US'].")", function(){
  echo 'ABOUT_US';
});

Flight::start();

Produces this output:

$ curl http://localhost:8000/
HOME_PAGE
$ curl http://localhost:8000/homepage.html
HOME_PAGE
$ curl http://localhost:8000/about-us.html
ABOUT_US