f



what does "->" and "=>" do?

I have read through php.net manuals and have not see any mention about
what these operands actually do.  I have seen them used in a bunch of
different code lately and don't really understand.

Example 1:

// Legacy Function: Renders the Footer of the Theme
function themefooter() {
	global $engine, $index, $themepath;

	if ($index != 3) {
		$engine->do_themefooter($index);
	}

}


Example 2:

// get the color scheme
$colors = pnModAPIFunc('Xanthia','user','getSkinColors',
			array('skinid' => $skinID,
			'paletteid' => $paletteid));


If anyone can shed some light on this, it would be greatly
appreciated.

thanks,
brett.

0
5/16/2007 8:55:14 PM
comp.lang.php 32646 articles. 0 followers. Post Follow

5 Replies
1002 Views

Similar Articles

[PageSpeed] 37

*** planetbrett@gmail.com escribi�/wrote (16 May 2007 13:55:14 -0700):
> I have read through php.net manuals and have not see any mention about
> what these operands actually do.  I have seen them used in a bunch of
> different code lately and don't really understand.

->

http://es2.php.net/manual/en/function.array.php



=>

http://es2.php.net/manual/en/language.oop.php



Hope this helps,


-- 
-+ http://alvaro.es - �lvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programaci�n web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
0
5/16/2007 9:43:54 PM
On May 16, 3:55 pm, planetbr...@gmail.com wrote:
> I have read through php.net manuals and have not see any mention about
> what these operands actually do.  I have seen them used in a bunch of
> different code lately and don't really understand.
>
> Example 1:
>
> // Legacy Function: Renders the Footer of the Theme
> function themefooter() {
>         global $engine, $index, $themepath;
>
>         if ($index != 3) {
>                 $engine->do_themefooter($index);
>         }
>
> }
The -> return the attribute or calls the methods of an object The
above example calls the do_themefooter() method of whatever class
$engine is.
>
> Example 2:
>
> // get the color scheme
> $colors = pnModAPIFunc('Xanthia','user','getSkinColors',
>                         array('skinid' => $skinID,
>                         'paletteid' => $paletteid));
That's an array. The => means the the string on the right side (the
key) refers to the value on the left. You could access the value of
$skinID, for example like this:
$colors['skinid']
>
> If anyone can shed some light on this, it would be greatly
> appreciated.
>
> thanks,
> brett.


0
5/17/2007 2:50:44 AM
On May 16, 4:55 pm, planetbr...@gmail.com wrote:
> I have read through php.net manuals and have not see any mention about
> what these operands actually do.  I have seen them used in a bunch of
> different code lately and don't really understand.
>
> Example 1:
>
> // Legacy Function: Renders the Footer of the Theme
> function themefooter() {
>         global $engine, $index, $themepath;
>
>         if ($index != 3) {
>                 $engine->do_themefooter($index);
>         }
>
> }
>
> Example 2:
>
> // get the color scheme
> $colors = pnModAPIFunc('Xanthia','user','getSkinColors',
>                         array('skinid' => $skinID,
>                         'paletteid' => $paletteid));
>
> If anyone can shed some light on this, it would be greatly
> appreciated.
>
> thanks,
> brett.

Ok brett its pretty simple the difference between the two. In this
particular circumstance the two operators are used for very different
things. Example 1 is  a C like operator. Almost like an object in OOP
programming.
$engine is like a pointer to the value do_themefooter($index);
returns. Which is what happens in this sense.

Example 2
This is one of many ways to populate an array in php.
Instead of populating the array with a number based index, They have
chosen to populate the array using names instead of numbers. Ex.
$array[0] = "whatever";
                 Ex. $array('skinid' => $skinID);
This technique is pretty frequent in certain circumstances. So
$array['skinid'] refers to the value of $skinID.

Hope this was helpful.

Trey

0
thaertel (1)
5/17/2007 4:26:40 AM
Message-ID: <1179376000.892089.237520@e65g2000hsc.googlegroups.com> from
thaertel@gmail.com contained the following:

>                 Ex. $array('skinid' => $skinID);
>This technique is pretty frequent in certain circumstances. So
>$array['skinid'] refers to the value of $skinID.

I call it an 'andits'  As in

$key andits $value

:-)

-- 
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
0
blthecat (1680)
5/17/2007 6:53:50 AM
thaertel wrote:

> Example 1 is  a C like operator. Almost like an object in OOP
> programming. $engine is like a pointer to the value
> do_themefooter($index); returns. Which is what happens in this sense.

It's not "almost like" an object.

It is the operator that allows you to access properties and methods of an
object. It's analogous to the square brackets when using arrays. 

	$foo['bar'] is to arrays
	As $foo->bar is to objects.

Despite looking like a little arrow, it's not got anything to do with
pointers in a C sense of the word. $engine isn't a pointer to the value
do_themefooter($index) returns.

$engine is an object -- a "thing" of some kind, and it has a method
do_themefooter(). A "method" is just "something that an object is capable
of doing". So "$engine->do_themefooter()" just means: ask $engine to
perform its "do_themefooter()" action. Like this:

	$dog->chase($cat);

Dog isn't a "pointer to the cat chasing function". Dog is the thing that's
actively doing the chasing.

-- 
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
0
usenet200703 (299)
5/17/2007 12:38:31 PM
Reply:

Similar Artilces:

why have both "." and "->" ?
I used to remember why c++ needed both ? Could somebody help me here ? For example class A{ f(); }; A* aa; You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. Raj "raj" <rajkumar@hotmail.com> schreef in bericht news:d7fee6d0.0406230748.694b966b@posting.google.com... > I used to remember why c++ needed both ? > Could somebody help me here ? > > For example > > class A{ > f(); > }; > > A* aa; > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. > > Raj There is a difference I believe that xxxx->yyyy is used if xxxx is a pointer to an object/class and xxxx.yyyyy if xxxx is the object/classs > class A{ > f(); > }; > > A* aa; > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. IMHO it's simply convenience. Bye, Marco raj wrote: > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both > operators. The second form involves more typing and requires more effort to read. -- Russell Hanneken eunaarxra@cbobk.pbz Use ROT13 to decode my email address. In message <WOhCc.15115$Wr.8451@newsread1.news.pas.earthlink.net>, Russell Hanneken <me@privacy.net> writes >raj wrote: >> >> You could do either "aa->f()" or "(*aa...

What is the difference between "=>" and "->" operators?
Morning, I'm currently working my way through a series of tutorials from IBM's developer network called "Cook up Web sites fast with CakePHP". The XAMPP 1.4.9 development platform consists of PHP Version 5.0.2, MySQL 3.23.57. Here is an excerpt of code provided in the tutorial, which is used to create a model: <?php class Dealer extends AppModel { var $name = 'Dealer'; var $hasMany = array ('Product' => array( 'className' => 'Product', 'conditions'=>, 'order'=>, 'foreignKey'=>'dealer_id') ); } ?> Eclipse produces an error underneath the comma directly after the 'conditions' field, which says: "Parse error: "Static/scalar constant expected."" I changed the code above, got it working and continued through the tutorial: <?php class Dealer extends AppModel { var $name = 'Dealer'; var $hasMany = array ( "Product" => array("className","Product","conditions","order","foreignKey","dealer_id")); } ?> The system works fine until I used Bake to implement an ACL. Each time a new user registers, a rule is supposed to be enterred into the db which defines what access level they have, but it doesn't work. When a new user registers a new record should appear in the ACL tables. This is the only thing that I can think might have caused a problem. What is the differen...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By chance I created a small program as follows: =========== s : string := "CAT"; procedure modify ( s1 : out string ) is begin s1(2) := 'U'; end modify; ... put ( modify(s) ); =========== now I get as a result "CUT", and i dont understand why i get this result. Doesnt the "out" specify that its initial value isnt passed in via the parameter? But it seems to be passed in the above. In fact the "out" is acting like an "in out". I am a little confused. Could someone shed some light on this? Many thanks! zork "zork" <zork@nospam.com> wrote in message news:4104d5de@dnews.tpgi.com.au... > Hi i found the following explaination: > > In Ada, "in" parameters are similar to C++ const parameters. They are > effectively read-only within the scope of the called subprogram. > Ada "in out&q...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

indent string behavior: ">> " instead of "> > "
Hi all, the current indent string application seems to be rather basic: every quoted line is prefixed by the indent string. > Thus a quote like this one here will be requoted as > > Thus a quote like this one here will be requoted as However, I'd prefer some kind of set indent_string="> ?" which would insert one or no space after the quote character, or do some kind of "s/^> >/>>/" This can provide better readability both for plain text (since quoted text is more 'en bloc' and in shorter lines) and provide bet...

"new" [<TypeArguments>] <ClassOrInterfaceType> "(" [<ArgumentList>] ")"
According to http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.9 the following production holds <ClassInstanceCreationExpression> ::= "new" [<TypeArguments>] <ClassOrInterfaceType> "(" [<ArgumentList>] ")" What would be an example for a class instance creation expression with type arguments? Here's a reminder about those: <TypeArguments> ::= "<" <TypeArgument> {"," <TypeArgument>} ">" What I would understand would be: <ClassInstanceCre...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

What does this mean ==> ?", ",""
If I run ?", ","" in the immediate window, I get a comma followed by 13 spaces. It is difficult for me to understand this. MLH wrote: > If I run ?", ","" > in the immediate window, > I get a comma followed by 13 spaces. > It is difficult for me to understand this. Have you made sure the HELP file is working? Have you ever actually opened it? commas put data in the debug window into columns. Some people learn by experimentation... some don't. I guess you fit into the latter category. Try this ?"a";"b" You'll get ab Try this ?"a","b" You'll get a b The semi-colon (;) separator means put the results straight after each other the comma (,) separator means put a tab between them (only of course it's not a tab it's x number of spaces. A colon (:) is a line separator in the debug window as well as in code so ?"a";"b":debug.Print "c";"d" returns ab cd And ?"a","b":debug.Print "c","d" returns a b c d and you can do stuff like x = "a": debug.Print x Which returns a To return to your post ?", ","" Means print a literal comma (",") and then a tab (,) and then an empty string (""). -- Terry Kreft "MLH" <CRCI@NorthState.net> wrote in message news:n4f192d189pbiu6mfu2dc...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Is "a >= b" equivalent to "a
Hi! Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++? Is this equivalence an IEEE/ANSI rule? Or is this machine/compiler dependent? Any references are welcome! Thanks in advance, Humberto. It is not the same. Consider (a-b) is smaller than the smallest possible value. A special case of this are unsigned types. marc <hjbortol@mat.puc-rio.br> wrote in message news:1126098844.923109.50250@g44g2000cwa.googlegroups.com... > Hi! > > Is the expression "a >= b" equivalent to "a - b >= 0" in C/C++? > Is this e...

"." vs "->" operators
(I am using gcc 3.2 on RH 8) int name (struct str *name) I call the above function like this: struct str buf; int conf = name(&buf); int j; for (j=0; buf.address[j]; j++) { printf("%c", buf.address[j]); } If I do buf->address[j] instead of buf.address[j], it gives me error.. Why's that? aren't they the same thing? Bit confused! Ben Ben wrote: > If I do buf->address[j] instead of buf.address[j], it gives me error.. > Why's that? aren't they the same thing? No. buf->address[j] is equivelant to (*buf).address[j] "Ben" <crescent_au@yahoo.com> wrote in message news:d99e1341.0407130632.23604617@posting.google.com... > (I am using gcc 3.2 on RH 8) > > int name (struct str *name) > > I call the above function like this: > struct str buf; > int conf = name(&buf); > int j; > > for (j=0; buf.address[j]; j++) { > printf("%c", buf.address[j]); > } > > If I do buf->address[j] instead of buf.address[j], it gives me error.. It should. > Why's that? aren't they the same thing? Not at all. Why would you think so? '.' is used to select a member from a struct object 'directly' , using the struct object's name. '->' is used to select a member from a struct object 'indirectly', using a pointer to that struct object. struct s { int member; }; struct s obj; /* struct */ str...

"between" vs. ">= and <="
Hi, a client of us requested to replace ">= and <=" with "between" with a TIMESTAMP column. Unfortunately I am still waiting for his justification... In the meantime I thought I do some researching. Personally I cannot think of any reason why one or the other should be more efficient. I did some simplistic testing but no difference visible. (Experimental code at end.) I even believe that I once had found a statement saying that there is no difference performance wise. Any pointers? Kind regards robert SQL> show release release 1002000400 SQL> set echo on SQL> set pagesize 100 linesize 100 SQL> create table t1 2 as 3 select systimestamp + level as ts 4 from dual 5 connect by level <= 1000000 6 / Table created. SQL> begin 2 dbms_stats.gather_schema_stats( 3 user, 4 method_opt => 'FOR ALL COLUMNS SIZE AUTO', 5 granularity => 'AUTO', 6 cascade => true, 7 options => 'GATHER', 8 degree => null 9 ); 10 end; 11 / PL/SQL procedure successfully completed. SQL> set autotrace traceonly SQL> select * 2 from t1 3 where ts between systimestamp + 10000 and systimestamp + 10001 4 / Execution Plan ---------------------------------------------------------- Plan hash value: 3332582666 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T...

why "." and "->" operators ? #2
I used to remember why c++ needed both. For example class A{ f(); }; A* aa; You could do either "aa->f()" or "(*aa).f()". So why does C++ need both operators. Raj posted: > I used to remember why c++ needed both. > > For example > > class A{ > > f(); > > }; > > > > A* aa; > > > > You could do either "aa->f()" or "(*aa).f()". So why does C++ need both > operators. > > > > Raj It doesn't, just as we humans don't need tea or coffee. -JK...

Any function can convert the words form,such as "boys"->"boy","became->become".
Now,I prepare to write a English-Chinese dictionary.So I want find a function or library can convert the words from one form to another,such as "boys"->"boy","became->become","went"->"go". Because there is so many unregular convertions in English then I think it will be a hard work if do it by myself. Thanks. ...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience working in UNIX environment. Good working knowledge of Oracle RDBMS and PL/SQL) Note : Please send your updated resume along with contact no to Karthik@bhaninfo.com. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com # 1572, 7 th Floor Suites, 1 Blue Hill Plaza Pearl River,NY-10965 www.bhaninfo.com ...

Passing "<", ">", "=", etc as an argument to a method?
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double[] array,double val,String relationalOp) { List list = new ArrayList(); for (int m = 0;m < array.length;m++) { // The following line is the problem if (array[m] relationalOp val) { list.add(array[m]); } } return list; } //=========================================== Is it possible to use an argument directly in an if statement like that? I am trying to avoid havin...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

puts "\\".gsub("\\", "\\\\")
Hello, I have a mini-ruby quiz. Guess what this line of code writes to the console, then try it for yourself: puts "\\".gsub("\\", "\\\\") Why is that so? Martin From: martinus [mailto:martin.ankerl@gmail.com]=20 # Hello, I have a mini-ruby quiz. Guess what this line of code writes to # the console, then try it for yourself: # puts "\\".gsub("\\", "\\\\") puts "\\".gsub("\\", "\\\\") \ #=3D> nil # Why is that so? faq. escaping the escape in sub/gsub. search the archives. maybe you want somethin...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

my own perl "dos->unix"/"unix->dos"
i made a dos to unix, unix to dos program catered for my own purposes. it's seems to work fine. small program, 26 lines anyone see any potential problems with it? do you have a better way to do it? my next step is to slip in some code to automatically "detect" whether its a unix or dos file. #!/usr/bin/perl -w use strict; #setting based on filename argument. # if sym link is dos-unix or if sym link is unix-dos my ($from, $to); my $option=substr($0,rindex($0,'/')+1,length($0)-1); # $0 gives full path. this code gives just filename if ($option eq "dos-unix"){ ...

What is the function similar to ">>" of C and "Input" of Basic
Part of my data file looks like the paragraph below. I need to first find "s", and then read the number (998) after it. Then find "vals", and start reading the following 998 data. I have done this both in Visual C++ and Basic using ">>" and "Input" separately. What's the corresponding function for MATLAB? "fscanf" ignores the blankspace delimiator and puts the whole string together. Thank you in advance. Baodong 1 d 1 u 0 s 998 m 0 c 2 9.99000E-01 1.00000E+00 e 0 t 0 vals 2.68310E-09 0.0680 8.45751E-...

"=>" fails to quote
=> fails to quote some bare identifiers to the left of it - is this a known "feature"? test program: #! /usr/bin/perl -w %server = ('66.185.33.35'=>ascend06) ; for $key (keys %server) { print "<$key>\t<$server{$key}>\n" ; } %server = (66.185.33.35=>ascend06) ; for $key (keys %server) { print "<$key>\t<$server{$key}>\n" ; } %server = ( "66.185.33.35"=>ascend06) ; for $key (keys %server) { print "<$key>\t<$server{$key}>\n" ; } output: <66.185.33.35> <ascend06> &l...

Re: "out" and "in out"
"no reliable initial value" means, you cannot rely on the value, but it may have a value. This depends on the parameter passing mechanism, which is _not_ related to the parameter mode (contrary to what many people think). So the parameter mode is there (nearly) solely for the information of the reader. The parameter passing mechanism for all kinds of parameters is defined in the RM. There are parameters passed by copy (in and out), by reference; for some it is explicitly left undefined. In your case, the passing mechanism is by reference, so you get what you get. But don't rely on this, rely only on the mode, i.e. the parameter st is undefined upon entering the procedure modify, so when you only write component 2, upon return, only component 2 has been written. Under slight variations, the result of your code might be <garbage character>U<garbage character>. Another thing: Don't rely upon s1'First = 1. Component 2 might not exist. You could call modify like so: X: String (25..30); modify (X); Now s1(2) inevitably will raise Constraint_Error. ____________________________________________________ Aufnehmen, abschicken, nah sein - So einfach ist WEB.DE Video-Mail: http://freemail.web.de/?mc=021200 "Christoph Karl Walter Grein" <AdaMagica@web.de> wrote: > > In your case, the passing mechanism is by reference, so you get what you get. But don't rely on this, rely only on the mode, i.e. the parameter st is undefined...

Web resources about - what does "->" and "=>" do? - comp.lang.php

Resources last updated: 3/23/2016 8:18:21 PM