• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP us函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中us函数的典型用法代码示例。如果您正苦于以下问题:PHP us函数的具体用法?PHP us怎么用?PHP us使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了us函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     $sequence = new Charcoal_SequenceHolder(new Charcoal_Sequence(), new Charcoal_Sequence());
     // form token component
     $form_token = $context->getComponent('form_token@:charcoal:form');
     $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
     $config->set('token_key', 'foo');
     $form_token->configure($config);
     switch ($action) {
         case "form_token1":
             $token = $form_token->generate($sequence);
             echo "token: {$token}" . PHP_EOL;
             $this->assertNotNull($token);
             $this->assertNotEmpty($token);
             break;
         case "form_token2":
             // save my ticket into sequence
             $token_list = $sequence->get('token_key');
             $token_list[] = 'my-ticket';
             $sequence->set('foo', $token_list);
             // validation token will success
             $form_token->validate($sequence, 'my-ticket');
             break;
         case "form_token3":
             // save my ticket into sequence
             $token_list = $sequence->get('token_key');
             $token_list[] = 'my-ticket';
             $sequence->set('foo', $token_list);
             // validation token will fail
             $this->setExpectedException('Charcoal_FormTokenValidationException');
             $form_token->validate($sequence, 'another-ticket');
             break;
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:38,代码来源:FormTokenTestTask.class.php


示例2: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     switch ($action) {
         case "split_params1":
             $args_commandline = "foo bar baz";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             $extected = array("foo", "bar", "baz");
             $this->assertEquals($extected, $actual);
             return TRUE;
         case "split_params2":
             $args_commandline = "foo\\'s bar\\'s 'baz'";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             $extected = array("foo's", "bar's", "baz");
             $this->assertEquals($extected, $actual);
             return TRUE;
         case "split_params3":
             $args_commandline = "'Teacher\\'s Voice' \"Teacher\\'s Voice\" 'Teacher\\\"s Voice'";
             $actual = Charcoal_CommandLineUtil::splitParams(s($args_commandline));
             print_r($actual);
             $extected = array("Teacher's Voice", "Teacher's Voice", "Teacher\"s Voice");
             $this->assertEquals($extected, $actual);
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:CommandLineUtilTestTask.class.php


示例3: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->task_manager = us($config->getString('task_manager', ''));
     $this->forward_target = us($config->getString('forward_target', ''));
     $this->modules = uv($config->getArray('modules', array()));
     $this->events = uv($config->getArray('events', array()));
     $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE));
     $this->log_enabled = ub($config->getBoolean('log_enabled'));
     $this->log_level = us($config->getString('log_level'));
     $this->log_loggers = uv($config->getArray('log_loggers'));
     // eventsに記載しているイベントのモジュールも読み込む
     if (is_array($this->events)) {
         foreach ($this->events as $event) {
             $pos = strpos($event, "@");
             if ($pos !== FALSE) {
                 $this->modules[] = substr($event, $pos);
             }
         }
     }
     if ($this->getSandbox()->isDebug()) {
         log_info("system, debug, config", "task_manager:" . $this->task_manager, self::TAG);
         log_info("system, debug, config", "forward_target:" . $this->forward_target, self::TAG);
         log_info("system, debug, config", "modules:" . print_r($this->modules, true), self::TAG);
         log_info("system, debug, config", "events:" . print_r($this->events, true), self::TAG);
         log_info("system, debug, config", "debug_mode" . $this->debug_mode, self::TAG);
         log_info("system, debug, config", "log_enabled" . $this->log_enabled, self::TAG);
         log_info("system, debug, config", "log_level" . $this->log_level, self::TAG);
         log_info("system, debug, config", "log_loggers" . print_r($this->log_loggers, true), self::TAG);
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:36,代码来源:AbstractProcedure.class.php


示例4: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     $test_data_dir = $context->getFile(s('%APPLICATION_DIR%/test_data/class/io'));
     switch ($action) {
         case "combined_regex":
             $filter1 = new Charcoal_RegExFileFilter(s('/sample_file1\\.txt/'));
             $filter2 = new Charcoal_RegExFileFilter(s('/sample_file[23]\\.txt/'));
             $filter = new Charcoal_CombinedFileFilter(v(array($filter1, $filter2)));
             $files = $test_data_dir->listFiles($filter);
             $files_found = array();
             foreach ($files as $file) {
                 $files_found[] = $file->getName();
             }
             $expected = array('sample_file1.txt', 'sample_file2.txt', 'sample_file3.txt');
             $this->assertEquals('array', gettype($files));
             $this->assertEquals(3, count($files));
             $this->assertEquals(array(), array_diff($files_found, $expected));
             return TRUE;
         case "combined_wildcard":
             return TRUE;
         case "combined_complexed":
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:CombinedFileFilterTestTask.class.php


示例5: __construct

 /**
  *    constructor
  *
  *    @param string|Charcoal_String $database         database name
  *    @param string|Charcoal_String $table          table name
  *    @param string|Charcoal_String $target_dir     target directory
  */
 public function __construct($database, $table, $target_dir)
 {
     parent::__construct();
     $this->database = us($database);
     $this->table = us($table);
     $this->target_dir = us($target_dir);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:14,代码来源:GenerateModelEvent.class.php


示例6: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $request = $context->getRequest();
     $action = us($action);
     // Qdmail
     $qdmail = $context->getComponent('qdmail@:qdmail');
     $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
     $config->set('qdsmtp.host', 'localhost');
     $config->set('qdsmtp.port', '25');
     $config->set('qdsmtp.from', '[email protected]');
     $config->set('qdsmtp.protocol', 'SMTP');
     $config->set('qdsmtp.user', '');
     $config->set('qdsmtp.pass', '');
     $qdmail->configure($config);
     switch ($action) {
         // Send mail
         case "send_mail":
             $to = $request->get("to");
             $from = "[email protected]";
             $subject = "test";
             $body = "test!!!";
             echo "to:" . $to . eol();
             $qdmail->sendMail($from, $to, $subject, $body);
             break;
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:QdmailTestTask.class.php


示例7: test

 /**
  * execute tests
  *
  * @param string $action
  * @param Charcoal_IEventContext $context
  *
  * @return boolean
  */
 public function test($action, $context)
 {
     $action = us($action);
     // temp file component
     /** @var Charcoal_TempFileComponent $tf */
     $tf = $context->getComponent('temp_file@:charcoal:file');
     switch ($action) {
         case "create":
             $file = $tf->create("test");
             $this->assertTrue($file->exists());
             $this->assertTrue($file->canRead());
             $this->assertEquals("test", $file->getContents());
             return TRUE;
         case "get_contents":
             $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt');
             $temp_file->putContents("test");
             $tf->setFile($temp_file);
             $this->assertEquals("test", $tf->getContents());
             return TRUE;
         case "put_contents":
             $temp_file = new Charcoal_File(CHARCOAL_TMP_DIR . '/tmpfile.txt');
             $tf->setFile($temp_file);
             $tf->putContents("cat");
             $this->assertTrue($temp_file->exists());
             $this->assertTrue($temp_file->canRead());
             $this->assertEquals("cat", $temp_file->getContents());
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:38,代码来源:TempFileTestTask.class.php


示例8: __construct

 public function __construct(Charcoal_String $file, Charcoal_Integer $line, Charcoal_Integer $range = NULL)
 {
     parent::__construct();
     $this->_file = us($file);
     $this->_line = ui($line);
     $this->_range = $range ? ui($range) : self::DEFAULT_RANGE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:7,代码来源:PhpSourceInfo.class.php


示例9: test

    /**
     * execute tests
     */
    public function test($action, $context)
    {
        echo "action:{$action}" . PHP_EOL;
        $request = $context->getRequest();
        $action = us($action);
        // Tidy
        $tidy = $context->getComponent('tidy@:html:repair:tidy');
        $config = new Charcoal_Config();
        $config->set('encoding', 'utf8');
        $tidy->configure($config);
        switch ($action) {
            case "parse_string":
                $html1 = <<<HTMLDATA1
<html>
  <head>
    <title>My Title</name>
  </head>
<BODY>

  <h1>Test Header</hh1>
    <form>Google</textarea>
    <textarea>http://google.com/</textarea></form>
  </company>
HTMLDATA1;
                $tidy->parseString($html1);
                show_with_children($tidy->root());
                return TRUE;
        }
        return FALSE;
    }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:33,代码来源:TidyTestTask.class.php


示例10: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE));
     $this->smarty->caching = 0;
     //$config->getBoolean( 'caching' )->unbox();
     $this->smarty->compile_check = ub($config->getBoolean('compile_check', FALSE));
     $this->smarty->template_dir = us($config->getString('template_dir', '', TRUE));
     $this->smarty->compile_dir = us($config->getString('compile_dir', '', TRUE));
     $this->smarty->config_dir = us($config->getString('config_dir', '', TRUE));
     $this->smarty->cache_dir = us($config->getString('cache_dir', '', TRUE));
     $this->smarty->left_delimiter = us($config->getString('left_delimiter', '{', FALSE));
     $this->smarty->right_delimiter = us($config->getString('right_delimiter', '}', FALSE));
     //        $this->smarty->default_modifiers     = $config->getArray( 'default_modifiers', array() )->unbox();
     $plugins_dir = uv($config->getArray('plugins_dir', array(), TRUE));
     // add default plugins_dir: Smarty/Smarty/plugins
     $reflector = new ReflectionClass($this->smarty);
     $plugins_dir[] = dirname($reflector->getFileName()) . '/plugins';
     $this->smarty->plugins_dir = $plugins_dir;
     log_debug("smarty", "smarty->plugins_dir=" . print_r($this->smarty->plugins_dir, true), self::TAG);
     log_debug("smarty", "smarty=" . spl_object_hash($this->smarty), self::TAG);
     if ($this->debug_mode) {
         $smarty_options = array('caching' => $this->smarty->caching, 'compile_check' => $this->smarty->compile_check, 'template_dir' => $this->smarty->template_dir, 'compile_dir' => $this->smarty->compile_dir, 'config_dir' => $this->smarty->config_dir, 'cache_dir' => $this->smarty->cache_dir, 'default_modifiers' => $this->smarty->default_modifiers, 'plugins_dir' => $this->smarty->plugins_dir, 'left_delimiter' => $this->smarty->left_delimiter, 'right_delimiter' => $this->smarty->right_delimiter);
         ad($smarty_options);
         foreach ($smarty_options as $key => $value) {
             log_debug('system, debug, smarty', "smarty option: [{$key}]=" . Charcoal_System::toString($value));
         }
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:34,代码来源:SmartyRendererTask.class.php


示例11: test

 /**
  * テスト
  */
 public function test($action, $context)
 {
     $action = us($action);
     switch ($action) {
         case "open":
             $this->handler->open('/foo/bar', 'test');
             $save_path = Charcoal_System::getObjectVar($this->handler, 'save_path');
             $session_name = Charcoal_System::getObjectVar($this->handler, 'session_name');
             $this->assertEquals('/foo/bar', $save_path);
             $this->assertEquals('test', $session_name);
             return TRUE;
         case "close":
             return TRUE;
         case "read":
             return TRUE;
         case "write":
             $id = Charcoal_System::hash();
             $sess_data = 'test session data';
             $this->handler->open('/foo/bar', 'test');
             $this->handler->write($id, $sess_data);
             $criteria = new Charcoal_SQLCriteria(s('session_id = ?'), v(array($id)));
             $dto = $this->gw->findFirst(qt('session'), $criteria);
             $this->assertEquals($sess_data, $dto->session_data);
             $this->assertEquals('test', $dto->session_name);
             return TRUE;
         case "destroy":
             return TRUE;
         case "gc":
             return TRUE;
     }
     return FALSE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:35,代码来源:SmartGatewaySessionHandlerTestTask.class.php


示例12: processEvent

 /**
  * イベントを処理する
  *
  * @param Charcoal_IEventContext $context
  *
  * @return boolean
  */
 public function processEvent($context)
 {
     $request = $context->getRequest();
     // パラメータを取得
     $database = us($request->getString('p2'));
     $table = us($request->getString('p3'));
     //=======================================
     // Confirm input parameters
     //=======================================
     if (!empty($database) && !preg_match('/^[0-9a-zA-Z_\\-]*$/', $database)) {
         print "Parameter 2(database name) is wrong: {$database}" . PHP_EOL;
         return b(true);
     }
     if (!empty($table) && !preg_match('/^[0-9a-zA-Z_\\-]*$/', $table)) {
         print "Parameter 3(table name) is wrong: {$table}" . PHP_EOL;
         return b(true);
     }
     //=======================================
     // Send new project event
     //=======================================
     /** @var Charcoal_IEvent $event */
     $event_path = 'show_table_event@:charcoal:db:show:table';
     $event = $context->createEvent($event_path, array($database, $table));
     $context->pushEvent($event);
     return b(true);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:33,代码来源:ShowTableCommandTask.class.php


示例13: __construct

 /**
  *    constructor
  *
  *    @param string|Charcoal_String $app_name       application name
  *    @param string|Charcoal_String $project_name   project name
  *    @param string|Charcoal_String $target_dir     target directory
  */
 public function __construct($app_name, $project_name, $target_dir)
 {
     parent::__construct();
     $this->app_name = us($app_name);
     $this->project_name = us($project_name);
     $this->target_dir = us($target_dir);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:14,代码来源:NewAppEvent.class.php


示例14: configure

 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $session_name = $config->getString('session_name', '');
     $save_path = $config->getString('save_path', '', TRUE);
     $lifetime = $config->getInteger('lifetime', 0);
     $valid_path = $config->getString('valid_path', '');
     $valid_domain = $config->getString('valid_domain', '');
     $ssl_only = $config->getBoolean('ssl_only', FALSE);
     $save_path = us($save_path);
     $lifetime = ui($lifetime);
     $ssl_only = ub($ssl_only);
     $session_name = us($session_name);
     // デフォルトのセッション保存先
     if (!$save_path || !is_dir($save_path)) {
         $save_path = Charcoal_ResourceLocator::getApplicationPath('sessions');
     }
     // セッション初期化処理
     //        session_set_cookie_params( $lifetime, "$valid_path", "$valid_domain", $ssl_only );
     session_save_path($save_path);
     //        $session_name = session_name( $session_name ? $session_name : APPLICATION );
     session_name("PHPSESSID");
     //session_regenerate_id( TRUE );
     if ($this->getSandbox()->isDebug()) {
         log_debug("session", "session_name:{$session_name}", self::TAG);
         log_debug("session", "save_path:{$save_path}", self::TAG);
         log_debug("session", "lifetime:{$lifetime}", self::TAG);
         log_debug("session", "valid_path:{$valid_path}", self::TAG);
         log_debug("session", "valid_domain:{$valid_domain}", self::TAG);
         log_debug("session", "ssl_only:{$ssl_only}", self::TAG);
     }
     // メンバーに保存
     $this->save_path = $save_path;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:39,代码来源:DefaultSessionHandler.class.php


示例15: processEvent

 /**
  * process event
  *
  * @param Charcoal_IEventContext $context   event context
  *
  * @return boolean
  */
 public function processEvent($context)
 {
     $request = $context->getRequest();
     // get command line options
     $cmd_path = us($request->getString('p2'));
     $options = array('@:help' => '[command_path]', '@:version' => '', '@:db:generate:model' => 'databse table [target directory]', '@:db:show:table' => 'databse table');
     $examples1 = array('@:help' => '@:version => show "@:version" command help', '@:db:generate:model' => 'charcoal blog => generate "blog" table\'s model files in "charcoal" database' . '(model files are generated into current directory).', '@:db:show:table' => 'charcoal blog => show description about "blog" table in "charcoal" database.');
     $examples2 = array('@:help' => 'list => show all supported commands("list" can be omitted)');
     $descriptions = array('@:help' => 'show command help or list all command paths', '@:version' => 'show framework version.', '@:db:generate:model' => 'create model files into [target directory].', '@:db:show:table' => 'show table description');
     if (empty($cmd_path) || $cmd_path == 'list') {
         // show all commands
         echo "Supported command list: ";
         foreach ($options as $path => $opt) {
             echo "\n  " . $path;
         }
     } elseif (isset($options[$cmd_path])) {
         echo "How to use: ";
         echo "\n  charcoal " . $cmd_path . ' ' . $options[$cmd_path];
         if (isset($examples1[$cmd_path])) {
             echo "\nExample:";
             echo "\n  charcoal " . $cmd_path . ' ' . $examples1[$cmd_path];
             if (isset($examples2[$cmd_path])) {
                 echo "\n  charcoal " . $cmd_path . ' ' . $examples2[$cmd_path];
             }
         }
         if (isset($descriptions[$cmd_path])) {
             echo "\n\nThis command " . $descriptions[$cmd_path];
         }
     } else {
         echo "Command not found: {$cmd_path}";
     }
     echo "\n";
     return b(true);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:41,代码来源:HelpTask.class.php


示例16: test

 /**
  * execute tests
  */
 public function test($action, $context)
 {
     $action = us($action);
     // create token generator object
     $generator = $context->createObject('simple', 'token_generator');
     switch ($action) {
         case "simple_default":
             // create token generator object
             $token = $generator->generateToken();
             $this->assertEquals(strlen($token), 40);
             $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false);
             echo "default token: {$token}";
             break;
         case "simple_sha1":
             $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
             $config->set(s('algorithm'), 'sha1');
             $generator->configure($config);
             $token = $generator->generateToken();
             $this->assertEquals(strlen($token), 40);
             $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false);
             echo "sha1 token: {$token}";
             break;
         case "simple_md5":
             $config = new Charcoal_Config($this->getSandbox()->getEnvironment());
             $config->set(s('algorithm'), 'md5');
             $generator->configure($config);
             $token = $generator->generateToken();
             $this->assertEquals(strlen($token), 32);
             $this->assertEquals(preg_match("/[^0-9a-zA-Z]+/", $token), false);
             echo "md5 token: {$token}";
             break;
     }
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:36,代码来源:TokenGeneratorTestTask.class.php


示例17: formatMessage

 /**
  * Format message
  */
 public function formatMessage(Charcoal_LogMessage $msg)
 {
     //        Charcoal_ParamTrait::validateIsA( 1, 'Charcoal_LogMessage', $msg );
     $level = $msg->getLevel();
     $tag = $msg->getTag();
     $message = $msg->getMessage();
     $file = $msg->getFile();
     $line = $msg->getLine();
     $time = date("y/m/d H:i:s");
     // Convert encoding
     $message = $this->convertEncoding(s($message));
     // Get now time
     $now_time = time();
     // set log format string as initial value
     $out = $this->log_format;
     // logging context specific values
     $now_time = time();
     $log_values = array('%Y4%' => date("Y", $now_time), '%Y2%' => date("y", $now_time), '%M2%' => date("m", $now_time), '%M1%' => date("n", $now_time), '%D2%' => date("d", $now_time), '%D1%' => date("j", $now_time), '%H2%' => date("H", $now_time), '%H1%' => date("G", $now_time), '%h2%' => date("h", $now_time), '%h1%' => date("g", $now_time), '%M%' => date("i", $now_time), '%S%' => date("s", $now_time), '%LEVEL%' => $level, '%TAG%' => $tag, '%MESSAGE%' => $message, '%FILE%' => $file, '%FILENAME%' => $file, '%LINE%' => $line);
     // replace keyword
     foreach ($log_values as $key => $value) {
         $out = str_replace($key, $value, us($out));
     }
     // replace environment values
     $out = $this->getSandbox()->getEnvironment()->fill($out);
     return $out;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:29,代码来源:AbstractLogger.class.php


示例18: __construct

 /**
  *    Constructor
  *
  * @param string|Charcoal_String $section
  * @param string|Charcoal_String $action
  * @param boolean|Charcoal_Boolean $success       If TRUE, the test succeeded
  */
 public function __construct($section, $action, $success)
 {
     parent::__construct();
     $this->section = us($section);
     $this->action = us($action);
     $this->success = ub($success);
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:14,代码来源:TestResultEvent.class.php


示例19: loadClass

 public function loadClass($class_name)
 {
     $debug = $this->getSandbox()->isDebug();
     $class_name = us($class_name);
     $class_paths = self::$class_paths;
     // フレームワークのクラスではない場合はFALSEを返却
     if (!isset($class_paths[$class_name])) {
         //            log_info( "system,debug,class_loader", "class_loader", "[FrameworkClassLoader] Can not load class: [$class_name]" );
         if ($debug) {
             echo "Class NOT found in framework class loader: {$class_name}" . eol();
         }
         return FALSE;
     }
     // クラス名からクラスパスを取得
     $file_name = $class_name . '.class.php';
     $pos = strpos($file_name, 'Charcoal_');
     if ($pos !== FALSE) {
         $file_name = substr($file_name, $pos + 9);
     }
     $class_path = CHARCOAL_HOME . '/src/' . $class_paths[$class_name] . '/' . $file_name;
     //        log_info( "system,debug,class_loader", "class_loader", "[FrameworkClassLoader] class_path=[$class_path] class_name=[$class_name]" );
     // ソース読み込み
     Charcoal_Framework::loadSourceFile($class_path);
     if ($debug) {
         echo "Class found in framework class loader: {$class_name}" . eol();
     }
     return TRUE;
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:28,代码来源:FrameworkClassLoader.class.php


示例20: find

 /**
  * find elements
  *
  * @param Charcoal_String|string $selector
  * @param Charcoal_Integer|integer $index
  */
 public function find($selector, $index = NULL)
 {
     Charcoal_ParamTrait::validateString(1, $selector);
     Charcoal_ParamTrait::validateInteger(2, $index, TRUE);
     if (!$this->simple_html_dom) {
         _throw(new SimpleHtmlDomComponentException("SimpleHtmlDom object is not created"));
     }
     $selector = us($selector);
     log_debug("debug", "index:{$index}");
     if ($index !== NULL) {
         // returns single element
         $index = ui($index);
         log_debug("debug", "returns single element");
         $result = $this->simple_html_dom->find($selector, $index);
         log_debug("debug", "result: " . print_r($result, true));
         return $result ? new Charcoal_SimpleHtmlDomElement($result) : NULL;
     }
     // returns all elements
     log_debug("debug", "selector:" . print_r($selector, true));
     $result = $this->simple_html_dom->find($selector);
     log_debug("debug", "result: " . print_r($result, true));
     $elements = array();
     foreach ($result as $e) {
         $elements[] = new Charcoal_SimpleHtmlDomElement($e);
     }
     return $result ? $elements : array();
 }
开发者ID:stk2k,项目名称:charcoalphp2,代码行数:33,代码来源:SimpleHtmlDomComponent.class.php



注:本文中的us函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP usage函数代码示例发布时间:2022-05-23
下一篇:
PHP urr函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap