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?

Edited by Stefany93
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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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