Jump to content

Archived

This topic is now archived and is closed to further replies.

Stefany93

The "var" keyword in CodeIgniter

Recommended Posts

Hello fellows,

 

I have noticed that CodeIgniter has the "var" keyword in front of all of its predefined class properties like this:

 

 

      class CI_Session {
var $sess_encrypt_cookie = FALSE;
// more code here 
}

 

I know that the "var" keyword was used back in PHP 4 to define a variable, but no one still uses PHP 4 anyways, so could you please tell me why the hell CodeIgniter still puts "var" in front of properties?

Share this post


Link to post
Share on other sites

Wow, NO ONE uses PHP 4? I'd love to see how you came to that conclusion. There's a lot of hosts offering an option that NO ONE uses.

Share this post


Link to post
Share on other sites

Basically, you are right that nobody uses it, or nobody codes in it if they have the choice, but of course as teynon pointed out some people have no choice and CodeIgniter have ensured they still support it for that reason.

 

Of course Jessica doesn't always respond in such an unhelpful way. I see you were only asking a question.

Share this post


Link to post
Share on other sites

I'd say Jessica responded appropriately. The question was formed in a very heavy tone and very biased. Her comment was to the point. As for asking a question, I'd say this was formed more as a rant than a question.

Share this post


Link to post
Share on other sites

So if we're going to rant about CI's conventions, has anyone ever read their "style guide"?

http://ellislab.com/codeigniter/user-guide/general/styleguide.html#logical_operators

 

"Use of || is discouraged as its clarity on some output devices is low (looking like the number 11 for instance)."

 

One might argue that someone who confuses if($foo || $bar) and if($foo 11 $bar) might have enormous difficulty with the rest of the code as well. Really. foo 11 bar... come on.

Share this post


Link to post
Share on other sites

Also, there's nothing that says you can't use var past PHP 4. The documentation simply says it will be treated the same as public. What's wrong with that?

Share this post


Link to post
Share on other sites

Remove the word 'hell' and it's one of the nicest worded questions I've seen.

"You're not very smart." Remove the word not, and it's a pretty nice statement as well.

Share this post


Link to post
Share on other sites

"You're not very smart." Remove the word not, and it's a pretty nice statement as well.

 

No, remove the word 'not' and your statement means the opposite. Remove the word 'hell' from the question in this topic and it means the same thing. You're removing a word to make a sentence mean the opposite, it's a poor example.

Share this post


Link to post
Share on other sites

Alright guys enough.

Share this post


Link to post
Share on other sites

could you please tell me why the hell CodeIgniter still puts "var" in front of properties?

Simply because no-one got around to updating those particular properties yet. There is nothing more to read into it than that. :shy:

Share this post


Link to post
Share on other sites

CodeIgniter dropped support for PHP4 a while back, but nobody got around to updating the 2.1.X branch because they are focusing their efforts on v3. If you take a look at v3 on github you will see that the session class and the whole framework has been updated. No more var. I will use CodeIgniter 2.1.3, and the var doesn't hurt, even on PHP 5.4.X. It may not be the most elegant framework in the world, but it gets the job done. I don't think anyone is claiming CodeIgniter to be the best framework anymore, but 2.1.3 is stable, and I use it every day. I think in the future I'll be focusing on Slim, Laravel, and other frameworks.

Share this post


Link to post
Share on other sites

Thank you very much for the replies, fellow programmers! I understand now that the only reason "var" isn't removed is because the CodeIgniter development team doesn't want to in order to help folks who are still running on PHP4 for some reason.

 

Anyways, thank you.

Share this post


Link to post
Share on other sites

Thank you very much for the replies, fellow programmers! I understand now that the only reason "var" isn't removed is because the CodeIgniter development team doesn't want to in order to help folks who are still running on PHP4 for some reason.

Did you even read the replies?

 

The "var" is not being kept for PHP 4 compatibility, any version of CodeIgniter 2.0.0 or above requires PHP 5.

Share this post


Link to post
Share on other sites

I wouldnt say no one still uses PHP 4, but its definitely no need for any frameworks to compensate for PHP 4 users. They are minority nowadays, and PHP4 is not powerful enough to code most web applications. They are mostly for old applications written in the early days, no new softwares should be written with PHP 4 except in extremely rare cases when its the only available choice.

Share this post


Link to post
Share on other sites

×
×
  • 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.