source: www/manuals/PHP_manual/keyword.paamayim-nekudotayim.html@ 1

Last change on this file since 1 was 1, checked in by george, 18 years ago

Prvotní import všeho

File size: 4.4 KB
Line 
1<HTML
2><HEAD
3><TITLE
4>::</TITLE
5><META
6NAME="GENERATOR"
7CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
8REL="HOME"
9TITLE="Manuál PHP"
10HREF="index.html"><LINK
11REL="UP"
12TITLE="Classes and Objects"
13HREF="language.oop.html"><LINK
14REL="PREVIOUS"
15TITLE="Constructors"
16HREF="language.oop.constructor.html"><LINK
17REL="NEXT"
18TITLE="parent"
19HREF="keyword.parent.html"><META
20HTTP-EQUIV="Content-type"
21CONTENT="text/html; charset=ISO-8859-2"></HEAD
22><BODY
23CLASS="sect1"
24BGCOLOR="#FFFFFF"
25TEXT="#000000"
26LINK="#0000FF"
27VLINK="#840084"
28ALINK="#0000FF"
29><DIV
30CLASS="NAVHEADER"
31><TABLE
32SUMMARY="Header navigation table"
33WIDTH="100%"
34BORDER="0"
35CELLPADDING="0"
36CELLSPACING="0"
37><TR
38><TH
39COLSPAN="3"
40ALIGN="center"
41>Manuál PHP</TH
42></TR
43><TR
44><TD
45WIDTH="10%"
46ALIGN="left"
47VALIGN="bottom"
48><A
49HREF="language.oop.constructor.html"
50ACCESSKEY="P"
51>Pøedcházející</A
52></TD
53><TD
54WIDTH="80%"
55ALIGN="center"
56VALIGN="bottom"
57>Kapitola 14. Classes and Objects</TD
58><TD
59WIDTH="10%"
60ALIGN="right"
61VALIGN="bottom"
62><A
63HREF="keyword.parent.html"
64ACCESSKEY="N"
65>Dal¹í</A
66></TD
67></TR
68></TABLE
69><HR
70ALIGN="LEFT"
71WIDTH="100%"></DIV
72><DIV
73CLASS="sect1"
74><H1
75CLASS="sect1"
76><A
77NAME="keyword.paamayim-nekudotayim"
78></A
79><TT
80CLASS="literal"
81>::</TT
82></H1
83><DIV
84CLASS="caution"
85><P
86></P
87><TABLE
88CLASS="caution"
89BORDER="1"
90WIDTH="100%"
91><TR
92><TD
93ALIGN="CENTER"
94><B
95>Výstraha</B
96></TD
97></TR
98><TR
99><TD
100ALIGN="LEFT"
101><P
102>&#13; The following is valid for PHP 4 only.
103 </P
104></TD
105></TR
106></TABLE
107></DIV
108><P
109>&#13; Sometimes it is useful to refer to functions and variables
110 in base classes or to refer to functions in classes that
111 have not yet any instances. The :: operator is being used
112 for this.
113 </P
114><DIV
115CLASS="informalexample"
116><A
117NAME="AEN5737"
118></A
119><P
120></P
121><TABLE
122BORDER="0"
123BGCOLOR="#E0E0E0"
124CELLPADDING="5"
125><TR
126><TD
127><PRE
128CLASS="php"
129>class A
130{
131 function example()
132 {
133 echo "I am the original function A::example().&#60;br&#62;\n";
134 }
135}
136
137class B extends A
138{
139 function example()
140 {
141 echo "I am the redefined function B::example().&#60;br&#62;\n";
142 A::example();
143 }
144}
145
146// there is no object of class A.
147// this will print
148// I am the original function A::example().&#60;br&#62;
149A::example();
150
151// create an object of class B.
152$b = new B;
153
154// this will print
155// I am the redefined function B::example().&#60;br&#62;
156// I am the original function A::example().&#60;br&#62;
157$b-&#62;example();</PRE
158></TD
159></TR
160></TABLE
161><P
162></P
163></DIV
164><P
165>&#13; The above example calls the function example() in
166 class A, but there is no object of class A, so that
167 we cannot write $a-&#62;example() or similar. Instead we
168 call example() as a 'class function', that is, as a
169 function of the class itself, not any object of that
170 class.
171 </P
172><P
173>&#13; There are class functions, but there are no class variables.
174 In fact, there is no object at all at the time of the call.
175 Thus, a class function may not use any object variables (but
176 it can use local and global variables), and it may no use
177 $this at all.
178 </P
179><P
180>&#13; In the above example, class B redefines the function example().
181 The original definition in class A is shadowed
182 and no longer available, unless you are refering specifically
183 to the implementation of example() in class A using the
184 ::-operator. Write A::example() to do this (in fact, you
185 should be writing parent::example(), as shown in the next
186 section).
187 </P
188><P
189>&#13; In this context, there is a current object and it may
190 have object variables. Thus, when used from WITHIN an
191 object function, you may use $this and object variables.
192 </P
193></DIV
194><DIV
195CLASS="NAVFOOTER"
196><HR
197ALIGN="LEFT"
198WIDTH="100%"><TABLE
199SUMMARY="Footer navigation table"
200WIDTH="100%"
201BORDER="0"
202CELLPADDING="0"
203CELLSPACING="0"
204><TR
205><TD
206WIDTH="33%"
207ALIGN="left"
208VALIGN="top"
209><A
210HREF="language.oop.constructor.html"
211ACCESSKEY="P"
212>Pøedcházející</A
213></TD
214><TD
215WIDTH="34%"
216ALIGN="center"
217VALIGN="top"
218><A
219HREF="index.html"
220ACCESSKEY="H"
221>Domù</A
222></TD
223><TD
224WIDTH="33%"
225ALIGN="right"
226VALIGN="top"
227><A
228HREF="keyword.parent.html"
229ACCESSKEY="N"
230>Dal¹í</A
231></TD
232></TR
233><TR
234><TD
235WIDTH="33%"
236ALIGN="left"
237VALIGN="top"
238><TT
239CLASS="literal"
240>Constructors</TT
241></TD
242><TD
243WIDTH="34%"
244ALIGN="center"
245VALIGN="top"
246><A
247HREF="language.oop.html"
248ACCESSKEY="U"
249>Nahoru</A
250></TD
251><TD
252WIDTH="33%"
253ALIGN="right"
254VALIGN="top"
255><TT
256CLASS="literal"
257>parent</TT
258></TD
259></TR
260></TABLE
261></DIV
262></BODY
263></HTML
264>
Note: See TracBrowser for help on using the repository browser.