Jump to content

The "var" keyword in CodeIgniter


Stefany93

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?

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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:
Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Archived

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

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