本文整理匯總了PHP中MyClass::doSomething方法的典型用法代碼示例。如果您正苦於以下問題:PHP MyClass::doSomething方法的具體用法?PHP MyClass::doSomething怎麽用?PHP MyClass::doSomething使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MyClass
的用法示例。
在下文中一共展示了MyClass::doSomething方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: doSomething
use Gelembjuk\Locale\GetTextTrait;
public function doSomething()
{
echo $this->getText('welcome') . '<br>';
}
public function andAgainWelcome($name)
{
// use short call for getText
echo $this->_('hello', '', $name) . '<br>';
echo $this->_('contact', 'frontpage') . '<br>';
}
}
$obj = new MyClass();
// this meathod comes from a trait
$obj->setTranslation($translation);
$obj->doSomething();
$obj->andAgainWelcome($username);
echo '<br><br>';
// change to english
$obj->setLocale('en');
// and repeat
$obj->andAgainWelcome($username);
// =============================================================
echo '<h1>Test 3. Show language change select box</h1>';
// output form to change locale
$languages = new Gelembjuk\Locale\Languages(array('localespath' => $lang_folder_path));
echo '<hr><form name=\'langform\' method=\'GET\' action="index.php">';
echo $languages->getHTMLSelect(' name="locale" onchange="document.langform.submit()" ', $locale);
echo '</form>';
// =============================================================
// output EU languages
示例2: doSomething
<?php
interface MyInterface1
{
public function doSomething();
public function specialFunction1();
}
interface MyInterface2
{
public function doSomething();
// Prior to PHP 5.3.9 => FATAL ERROR
public function specialFunction2();
}
class MyClass implements MyInterface1, MyInterface2
{
function doSomething()
{
echo '...';
}
function specialFunction1()
{
echo '...';
}
function specialFunction2()
{
echo '...';
}
}
$a = new MyClass();
$a->doSomething();