extends [file] ?

General discussions related to php

Moderators: macek, egami, gesf

adahox
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Jul 11, 2013 7:07 pm

extends [file] ?

Postby adahox » Thu Jul 11, 2013 7:11 pm

hello,

how can i extends some class in other file?

exemple.
file one.php

Code: Select all

class One{}

file two.php

Code: Select all

class two extends one{}


how can i do it?

thanks fo all.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: extends [file] ?

Postby johnj » Thu Jul 11, 2013 10:58 pm

first include that file in your second file. Take a look at the include(), require_once() etc
http://php.net/manual/en/function.include.php

adahox
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Jul 11, 2013 7:07 pm

Re: extends [file] ?

Postby adahox » Fri Jul 12, 2013 4:03 am

i want do it without include_once, require or someting like.

i want do someting like cake. the controller call appcontroller class without include. get it?

thanks for all! :D

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: extends [file] ?

Postby johnj » Sat Jul 13, 2013 6:02 am

Whether you use include() or cake, the parent class has to be visible to the child for it to extend or inherit - there are no shortcuts here.

adahox
New php-forum User
New php-forum User
Posts: 4
Joined: Thu Jul 11, 2013 7:07 pm

Re: extends [file] ?

Postby adahox » Sat Jul 13, 2013 12:56 pm

:offtopic:


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron