} $greet = function ($name = "", $surname = "") { echo "hello! {$name} {$surname}\n"; #printf("Hello %d\r\n",$name); }; $greet('Ioannis', "Papagiannis"); $greet = "myprint"; $greet('Matteo %s'); $greet = "printf"; $greet('Matteo %s\\n', "rocks"); $c = 'cello'; $c = $c[0]; if ($c == 'c') { echo "\nIt is c!\n"; } myprint("Nick", "Carter"); printf("Hello World\n"); printf("from %s\n", "yiannis"); $x = rand(0, 0); printf("random number=%d\n", $x); if (isset($x)) { echo "x is actually set\n"; } else { echo "x is NOT set\n"; } if (empty($x)) { echo "x is actually empty\n"; } else { echo "x is NOT empty\n"; } die('-5');
function lang() { defined('PAGE_IS_NOT_TRANSLATED') or define('PAGE_IS_NOT_TRANSLATED', 666); static $defaults = array('json' => false, 'force' => false, 'namespace' => 'default', 'usenativelocale' => true); static $userIsTranslator; return func_get_arg(0); if (is_null($userIsTranslator)) { $acl = Zend_Registry::get('acl'); $user_role = class_exists('UserModel', false) ? UserModel::getCurrentUserInfo()->role : 'guest'; $userIsTranslator = $acl->isAllowed($user_role, 'translate'); } $args = $originalArgs = func_get_args(); $trString = array_shift($args); __log__("Want to translate string \"{$trString}\"", Zend_Log::INFO); //return $trString; $c = count($args); /* if(preg_match('/company/', $trString)){ de($args); } */ if ($c > 1 && is_array($args[$c - 1])) { $options = array_pop($args); } else { $options = array(); } if (isset($args[0])) { $args = is_array($args[0]) ? $args[0] : array($args[0]); } /* if(preg_match('/about -/', $trString)){ de($args); } */ $options += $defaults; if (Zend_Controller_Front::getInstance()->getRequest()->getModuleName() == 'admin') { $options['json'] = true; } $options['register_untranslated_words'] = !!Zend_Registry::get('configuration')->register_untranslated_words; $translate = Zend_Registry::get('translations')->{$options['namespace']}; $translate->getAdapter()->setLocale(Zend_Registry::get('locale')); if (is_null($translate)) { throw new Exception("No translation found under register {$options['namespace']}"); } /** * Do we have translation ? */ if ($translate->isTranslated($trString)) { $jsonStr = Zend_Json::encode($trString); $trString = $translate->translate($trString); if ($args) { $trString = myprint($trString, $args); } return $trString; if ($userIsTranslator && !$options['json']) { $trString .= "<a href='#' onclick='translate({$jsonStr},this,options)'>#</a>"; } return $trString; /** * Is the language of translation default ? */ } else { if ($translate->getAdapter()->getLocale() == 'uk_UA' && $options['usenativelocale']) { if (is_string($args)) { } return myprint($trString, $args); /** * Do we need to return original string ? */ } else { if ($userIsTranslator || $options['force']) { __log__("String is not translated but forced - \"{$trString}\"", Zend_Log::INFO); if ($options['register_untranslated_words']) { AdminTranslateModel::getInstance()->addTranslationString(Zend_Registry::get('lang'), $trString); } return myprint($trString, $args); # if (!$options['json']) { $jsonStr = Zend_Json::encode($trString); $trString .= "<a href='#' onclick='translate({$jsonStr},this,options)'>*</a>"; } return myprint($trString, $args); # } else { if (!UserController::isDispatchableNow()) { //Need to let user login __log__("String is not translated - \"{$trString}\"", Zend_Log::INFO); //throw new Exception('Sorry page is not translated yet', PAGE_IS_NOT_TRANSLATED); } } } } return myprint($trString, $args); }