Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by deathbeam

  1. So, I am not very experienced with regexes, so I wanna ask if this code can be simplified with preg_match? It is code from my framework on what I am working for adding routes. To explain what is "default" and "MAP", here is example usage. And, callable is called via call_user_func_array if that helps. // mapping routes $fw->route('home: GET|POST /', 'home'); // provide ReST interface by mapping HTTP requests to class method $fw->route('MAP /rest', 'some_class'); // default route (404 page) $fw->route('default', 'error'); And this is route method. public function route($pattern, $callable) { $pattern = strtr($pattern,array(' '=>'')); if ($pattern == 'default') { $this->default_route = $callable; return $this; } $arr = explode('/', $pattern, 2); $method = $arr[0]; $route = '/'.$arr[1]; if (strpos($arr[0], ':') !== false) { $arr = explode(':', $arr[0], 2); $name = $arr[0]; $method = $arr[1]; } if ($method == 'MAP') { foreach ((explode('|', self::Methods)) as $method) { $this->route((isset($name)?$name.':':null).$method.$route, $callable.'->'.strtolower($method)); } return $this; } $this->routes[] = array($method, $route, $callable, isset($name)?$name:null); return $this; }
  2. Gosh, that design is messy. Try http://getbootstrap.com/getting-started
  3. There is also another scenario. Like this: class base{ public function setParam($key, $callable){ $this->params[$key] = $callable; } internal function run(){ foreach($this->params as $key=>$callable) $callable(); } } $base = new Base(); // if internal was possible, users will not be able to call this method outside this file. Especially usefull for frameworks and PHP applications. $base->run(); If you know what I mean. And yes, PHP isn´t C#, but PHP hosting is cheaper than ASP.NET. So it is pity that internal does not exists in PHP.
  4. Yes, it have protected, private and public. But it misses internal. Internal functions and vars are visible only in file.
  5. Only thing I really miss from PHP is "internal" access modifier. Before I was making libraries and extensions in C# (like game frameworks, Tiled implementations, GUI loaders). Now, when I am working on my own PHP framework, I really miss internal, I was using it a lot in C#. Is internal planned to be added in PHP 7 or is it already in PHP 5.6 or it will never be added?
  6. If you are using windows, then simply download https://windows.github.com/ GitHub for windows so you do not have to learn git at all
  7. Welcome here. I personally do not like w3schools, but it have some valuable tutorials for beginners. Good luck with learning PHP
  8. Notepad++ becouse my PC is too slow to handle PHPStorm
  9. So I am just wondering to what music/genres you guys are listening too when working on something. This is somewhat forum game, so I will start. When I am programming something, I am mostly listening to metal (almost all genres of metal, including nu-metal and metalcore). Right now I am listening to Sabaton - Primo Victoria
  10. I think you should go with Java, it is probably best language right now (in terms of portability and cross-platform compatibility). C# is also worth trying becouse of Mono (what is cross-platform port of .NET) if you are interested in game development. And... C# is also good for web development (ASP.NET). I personally self-learned C# and now going to learn Java.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.