Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter future with PHP5
#21

[eluser]ci_man[/eluser]
@ lone
not really. I create a private function in a controller, then call it from url...

@ Michael
First, from all the posts I have so far, I have never mentioned to alienate php4 users...
Second, it is not insane for anyone in this forum to express their suggestions. That is what the forum for.
#22

[eluser]Pascal Kriete[/eluser]
[quote author="ci_man" date="1204100390"]
not really. I create a private function in a controller, then call it from url...
[/quote]

Ok, I just tried this and guess what, it didn't show up. Surprise!!!

Granted, it also tossed me a nasty php error instead of a pretty 404 but that's because it's not coded to do that. Why would you want private when you can have _ ?
#23

[eluser]Derek Jones[/eluser]
[quote author="ci_man" date="1204100390"]@ lone
not really. I create a private function in a controller, then call it from url...[/quote]

Actually, wouldn't that cause an error? I don't believe call_user_func_array() will view a private class method as a valid callback. In fact, that's actually a good motivation to change the method_exists() conditional in CodeIgniter.php for the controller method check to include is_callable(), so a 404 can be shown instead of generating a PHP error.
#24

[eluser]Lone[/eluser]
I don't get why you would be setting it as a private function in a controller if you want to access it from a URL?

IMO it shouldn't work - a private controller function is generally to be accessed by another function in the controller. And from what I gather how CI works it loads the controller class then runs that function, no matter if its in CI or not your never going to be able to do the following (thinking 'Page' as the controller):

Code:
class Page {
  private function view() {
    echo "test";
  }
}

$page = new Page;
$page->view();

Derek: A 404 would be a bit nicer for this one - of course a log mention with tried to load private would be handy for those staring at code and thinking "but it is there!"
#25

[eluser]Derek Jones[/eluser]
I believe I saw a feature request recently where logging of 404's would show the request, which sounds useful, and would accommodate this as well. As for creating private functions and accessing them from URLs - sure, you may not intend for your users to do so, but especially if your code for your application is public, you have to anticipate that someone will try to do so.
#26

[eluser]Derek Jones[/eluser]
Oh, and gotta love PHP. On many versions of 5.x, method_exists() and is_callable() will report as TRUE on private and protected class functions. Sheesh. So I guess we will have to take advantage of get_class_method()'s behavior of not returning private and protected methods when called from outside of the target class object.
#27

[eluser]Derek Jones[/eluser]
Ok, the change has been implemented in the svn, feedback is welcome (404s logged with controller/method, and private/protected functions no longer attempted to be accessed via URLs)
#28

[eluser]ci_man[/eluser]
That's Awesome, Derek! I sincerely appreciate all your help and time. I have to admit that I am new to CI, I need time to learn from you guys Smile

@lone
Sorry, I did not explain it well. You were right, I should not call a private function in a controller. But others might try to do so, especially when they don't see a "private" keyword in front.
#29

[eluser]mrahman[/eluser]
This is a bit off topic. But after around three years of working, are you guys still thinking the same way? I mean, as time goes and more old systems are being rewritten for enhancements, the PHP4 is dyeing really. I understand the people that would respond with "Kohana" or "Work your way PHP5 and let 4 support".. Yes but I thins is a kind of living in past! People who find it hard to switch the framework are far more than people who can't switch their PHP version. PHP6 will show up and what then? You can't have everything and support for many versions would really affect the quality and impede the development. PLUS: old systems may just "stick" and ignore future releases. I'm sure you guys faced challenges with many features just to keep the 4 support.
#30

[eluser]Vheissu[/eluser]
The only web hosts that don't support PHP 5 are the lowest of all hosting providers who are too cheap to upgrade to a version of PHP that was first released in 2004 when Zend Engine II showed up. That was almost 7 years ago.

I would never choose a host that didn't offer PHP5. That's like going to a computer shop that only sells PCs running Windows XP instead of Windows 7 (or at least Vista). Hostgator are like $10 a month for a really cheap plan with PH5 and other stuff, if you're being hosted elsewhere and paying more than Hostgator and don't get PHP5 included with your hosting account, it's time to switch.

Looks like PHP4 is going to be a burden to back-end development like IE6 is to web development.




Theme © iAndrew 2016 - Forum software by © MyBB