Jump to content


Photo

The "var" keyword in CodeIgniter


  • Please log in to reply
15 replies to this topic

#1 Stefany93

Stefany93

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts
  • Age:20

Posted 03 March 2013 - 01:15 PM

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, 03 March 2013 - 01:15 PM.

"Never take counsel of your fears!" - Stonewall Jackson
My site - http://dyulgerova.info


#2 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 03 March 2013 - 01:18 PM

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.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#3 teynon

teynon

    Advanced Member

  • Members
  • PipPipPip
  • 895 posts

Posted 03 March 2013 - 01:26 PM

This shows statistics of outward facing websites: http://w3techs.com/t.../pl-php/all/all

 

There are many inward facing (intranets) that still use PHP 4. My work FINALLY upgraded to 5.3. But they haven't pushed those changes out to customers yet.


Support my Kickstarter Project!
http://www.kickstart...7618755/antroid

http://www.thomaseynon.com

Vulnerabilities: http://cwe.mitre.org...x.html#Guidance - MySQL.com hacked with SQL Injection - If it happened to them, it can happen to you.


#4 johnsmith153

johnsmith153

    Advanced Member

  • Members
  • PipPipPip
  • 709 posts

Posted 03 March 2013 - 02:05 PM

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.



#5 teynon

teynon

    Advanced Member

  • Members
  • PipPipPip
  • 895 posts

Posted 03 March 2013 - 02:12 PM

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.


Support my Kickstarter Project!
http://www.kickstart...7618755/antroid

http://www.thomaseynon.com

Vulnerabilities: http://cwe.mitre.org...x.html#Guidance - MySQL.com hacked with SQL Injection - If it happened to them, it can happen to you.


#6 johnsmith153

johnsmith153

    Advanced Member

  • Members
  • PipPipPip
  • 709 posts

Posted 03 March 2013 - 02:15 PM

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



#7 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 03 March 2013 - 02:19 PM

So if we're going to rant about CI's conventions, has anyone ever read their "style guide"?
http://ellislab.com/...gical_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.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#8 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 03 March 2013 - 02:20 PM

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?
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#9 teynon

teynon

    Advanced Member

  • Members
  • PipPipPip
  • 895 posts

Posted 03 March 2013 - 02:36 PM

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.


Support my Kickstarter Project!
http://www.kickstart...7618755/antroid

http://www.thomaseynon.com

Vulnerabilities: http://cwe.mitre.org...x.html#Guidance - MySQL.com hacked with SQL Injection - If it happened to them, it can happen to you.


#10 johnsmith153

johnsmith153

    Advanced Member

  • Members
  • PipPipPip
  • 709 posts

Posted 03 March 2013 - 03:06 PM

"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.



#11 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 03 March 2013 - 03:13 PM

Alright guys enough.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#12 salathe

salathe

    Badger

  • Staff Alumni
  • 1,859 posts
  • LocationEdinburgh, Scotland

Posted 03 March 2013 - 07:01 PM

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:
PHP Documentation Team

#13 sKunKbad

sKunKbad

    Advanced Member

  • Members
  • PipPipPip
  • 1,737 posts
  • LocationTemecula, CA, USA

Posted 03 March 2013 - 07:28 PM

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.
Brian's Web Design - Temecula

Freedom is only available through death.

#14 Stefany93

Stefany93

    Advanced Member

  • Members
  • PipPipPip
  • 170 posts
  • Age:20

Posted 05 March 2013 - 02:24 PM

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.


"Never take counsel of your fears!" - Stonewall Jackson
My site - http://dyulgerova.info


#15 salathe

salathe

    Badger

  • Staff Alumni
  • 1,859 posts
  • LocationEdinburgh, Scotland

Posted 05 March 2013 - 02:54 PM

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.
PHP Documentation Team

#16 Hall of Famer

Hall of Famer

    OOP Fanboi

  • Members
  • PipPipPip
  • 315 posts
  • LocationIthaca

Posted 07 March 2013 - 07:12 PM

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.


Welcome to the world of OOPHP! In a perfect script, everything is an object. You cannot be perfect, but you can approach as close as can.

zog841.jpg





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com