physaux Posted November 11, 2009 Share Posted November 11, 2009 I can't seem to google for it effectively, and "arrows" isn't helping... So could someone tell me what this does? I have seen it in many sample codes. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/ Share on other sites More sharing options...
Mchl Posted November 11, 2009 Share Posted November 11, 2009 It can be used either to declare elements of array http://www.php.net/manual/en/language.types.array.php Or to declare key and value variables when using foreach http://www.php.net/manual/en/control-structures.foreach.php Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955636 Share on other sites More sharing options...
Daniel0 Posted November 11, 2009 Share Posted November 11, 2009 [...] and "arrows" isn't helping... It is actually called a T_DOUBLE_ARROW internally in PHP ("T" for token). Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955660 Share on other sites More sharing options...
GoneNowBye Posted November 11, 2009 Share Posted November 11, 2009 its also a common error for trying to specify greater then or equal to. and somtimes means "implied" in maths, <= means implied by -> is for class objects. Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955761 Share on other sites More sharing options...
Daniel0 Posted November 11, 2009 Share Posted November 11, 2009 its also a common error for trying to specify greater then or equal to. You can always remember that by its name. "Greater than or equal to", so it's first > (greater than) and then = (equal to), i.e. >=. Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955770 Share on other sites More sharing options...
GoneNowBye Posted November 11, 2009 Share Posted November 11, 2009 Problem there is though, is when you think though it i often thing "equal too or greater then" depending on what i'm solving.... i just know it comes first now anyway goodluck Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955791 Share on other sites More sharing options...
GoneNowBye Posted November 11, 2009 Share Posted November 11, 2009 it also means "here" on these forms, look at the jump to section just above quick reply sorry last one for now Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-955797 Share on other sites More sharing options...
physaux Posted November 14, 2009 Author Share Posted November 14, 2009 Hmm interesting thanks for the replies. It wasnt the "greater than or equal" mistake lol, but thanks for considering all the possibilities Ok, so I am trying to understand it. Here is a sample code where it is used. Could someone clear up for me what exactly is going on? <?php $employees [] = array( 'name' => 'Albert', 'age' => '34', 'salary' => "$10000" ); $employees [] = array( 'name' => 'Claud', 'age' => '20', 'salary' => "$2000" ); $doc = new DOMDocument(); $doc->formatOutput = true; ?> I can see that the first "=>" assigns an array, ok thats cool. But what is the second, "->" part do?? Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-957279 Share on other sites More sharing options...
Garethp Posted November 14, 2009 Share Posted November 14, 2009 $doc is a class. $doc->formatOutput is the variable "formatOutput" inside the class "$doc" Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-957280 Share on other sites More sharing options...
ngreenwood6 Posted November 14, 2009 Share Posted November 14, 2009 Hopefully this will help you physaux: by doing this: $employees [] = array( 'name' => 'Albert', 'age' => '34', 'salary' => "$10000" ); You are creating an associative array. What that means is instead of having an array with 0,1,2 as the index's the index's are what you set here. For example using the array above you could access the fields like this: $employees['name'] //would equal Albert $employees['age'] //would equal 34 $employees['salary'] //would equal $10000 //without named indexes it would be $employees[0] //would equal Albert $employees[1] //would equal 34 $employees[2] //would equal $10000 Now for this part: $doc = new DOMDocument(); $doc->formatOutput = true; What you are using there is a class. When you do $doc = new DOMDocument(); you are creating an instance of that class. Then $doc->formatOutput is setting a variable in that class. so for instance the class may look like this: class DOMDocument{ public formatOutput = false; public function helloWorld(){ echo 'hello world'; } } So by doing $doc->formatOutput it is then setting that to true instead. You can also access functions like that as well. So using the example above if you were to do this $doc->helloWorld(); it would output "hello world". All that is doing is making a reference to an object of that class. Hopefully that will clear some stuff up. Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-957295 Share on other sites More sharing options...
physaux Posted November 14, 2009 Author Share Posted November 14, 2009 Thanks, that really helped to clear stuff up!! :thumb-up: Quote Link to comment https://forums.phpfreaks.com/topic/181135-solved-newby-question-what-does-do/#findComment-957522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.