とりあえず5文型を覚えれるように。
英文法の勉強は眠くなるのに、これだと結構覚えやすい。
main(); } /** * 文型について * http://blog.livedoor.jp/aritouch/archives/1470991.html * * S : Subject (主語) * V : Verb (動詞) * O : Object (目的語) * C : Complement (補語) * M : Modifier (修飾語) */ public function main() { $He = new Person(); $You = new Person(); $I = new Person(); // SV // He runs in the park. echo $He->run(); echo PHP_EOL; echo $He->run('in the peark'); echo PHP_EOL; // SVC // You look happy. echo $You->look(); echo PHP_EOL; echo $You->look('happy'); echo PHP_EOL; // SVO // I have a book. echo $I->have(); echo PHP_EOL; echo $I->have('a book'); echo PHP_EOL; // SVOO // I gave her a doll. echo $I->give(); echo PHP_EOL; echo $I->give('her'); echo PHP_EOL; echo $I->give('her', 'a doll'); echo PHP_EOL; // SVOC // I call the dog Pochi. echo $I->call(); echo PHP_EOL; echo $I->call('the dog'); echo PHP_EOL; echo $I->call('the dog', 'Pochi'); echo PHP_EOL; } } /** * Personクラス */ class Person { /** * TEST */ public $_test = 'test'; /** * TEST */ public function getTest() { return $this->_test; } /** * run * */ public function run($adverb = null) { return (is_null($adverb)) ? 'run' : sprintf('run %s', $adverb); } /** * look * */ public function look($complement = null) { return (is_null($complement)) ? 'false' : sprintf('look %s', $complement); } /** * have * */ public function have($object = null) { return (is_null($object)) ? 'false' : sprintf('have %s', $object); } /** * give * */ public function give($object = null, $object2 = null) { return (is_null($object)) ? 'false' : (is_null($object2)) ? 'false' : sprintf('give %s %s', $object, $object2); } /** * call * */ public function call($object = null, $complement = null) { return (is_null($object)) ? 'false' : (is_null($complement)) ? 'false' : sprintf('call %s %s', $object, $complement); } }