下記ですと「Parse error: syntax error, unexpected T_INCLUDE, expecting T_FUNCTION…」とエラーになります。
現在は「action.class.php」にて
class memberActions extends sfActions {
include("/home/hoge/hoge.php");
public function executeIndex(sfWebRequest $request)
{
echo $hoge;
}
}
他に正しい記述方法などありますでしょうか?
メソッドの実装を外部のファイルに出したい、ということなんですね?
trait を使うと良いみたいです。
http://stackoverflow.com/questions/1957732/can-i-include-code-into-a-php-class
http://php.net/manual/ja/language.oop5.traits.php
外部のソース hoge.php 。
<?php trait Hoge { public function fuga () { ...; } } ?>
hoge.php を include するアクション。
<?php include 'hoge.php'; class memberActions extends sfActions { use Hoge; ... } ?>
trait とは少し違いました。
2012/12/17 11:51:51他の方法で回避策をしました。