appu
appu

Reputation: 97

How to interpret this PHP statement?

I would like to know what kind of variable is $firstLine in the following php code line. Is it a pointer or what ?

$firstLine=$myMovie->add($myShape1);

Thanks

OK here is the complete code:

  <html>
 <body>
  <? 
   $myShape1=new SWFShape(); 

   $myShape1->setLine(5,0,0,255); 

    $myShape1->drawLine(440,0); 

   $myMovie=new SWFMovie(); 

   $myMovie->setDimension(460,80); 
   $myMovie->setBackground(255,0,0); 

   $firstLine=$myMovie->add($myShape1); 
   $firstLine->moveTo(10,10); 

    $secondLine=$myMovie->add($myShape1); 
   $secondLine->moveTo(10,70); 

   $myMovie->save("lesson2.swf"); 

  ?> 

   <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"    codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" ID=objects        WIDTH=460 HEIGHT=80>
   <PARAM NAME=movie VALUE="lesson2.swf">
    <EMBED src="lesson2.swf" WIDTH=460 HEIGHT=80 TYPE="application/x-shockwave-flash"       PLUGINSPAGE="http://www.macromedia.com/shockwave/download /index.cgi?P1_Prod_Version=ShockwaveFlash">

       </body>
       </html>

Upvotes: 1

Views: 88

Answers (5)

Karolis
Karolis

Reputation: 9562

From PHP Manual:

For displayable types (shape, text, button, sprite), this returns an SWFDisplayItem, a handle to the object in a display list. Thus, you can add the same shape to a movie multiple times and get separate handles back for each separate instance.

You can also use var_dump($firstLine); to see what it returns.

Upvotes: 1

moteutsch
moteutsch

Reputation: 3831

$myMovie is an object that has a method (a fancy word for a function contained within a class) named add(). $firstLine simply contains the value returned from that method.

Upvotes: 0

James Allardice
James Allardice

Reputation: 165971

The variable $firstLine will contain whatever the method add returns. For example if add returns true, then $firstLine will contain true.

Upvotes: 0

Paul Manta
Paul Manta

Reputation: 31577

PHP does not have pointers as the C-like languages do. Instead — similarly to Java or C# — all instances of user-defined types are references. That means that if you do $firstLine = $otherLine, they are two references to the same data. In PHP you have to be explicit when you want to copy the actual data, not just the reference; see:
> http://php.net/manual/en/language.oop5.cloning.php

Upvotes: 0

CristiC
CristiC

Reputation: 22698

Depends what add function returns.

In your class - probably Movie (see where and how $myMovie was instantiated) you will find this add function. Check what it returns.

Upvotes: 1

Related Questions