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

PHP str函数代码示例

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

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



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

示例1: test

 /**
  * Stack test method.
  *
  * @param object IStack $stack The stack to test.
  */
 public static function test(IStack $stack)
 {
     printf("AbstractStack test program.\n");
     for ($i = 0; $i < 6; ++$i) {
         if ($stack->isFull()) {
             break;
         }
         $stack->push(box($i));
     }
     printf("%s\n", str($stack));
     printf("Using foreach\n");
     foreach ($stack as $obj) {
         printf("%s\n", str($obj));
     }
     printf("Using reduce\n");
     $stack->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), '');
     printf("Top is %s\n", str($stack->getTop()));
     printf("Popping\n");
     while (!$stack->isEmpty()) {
         $obj = $stack->pop();
         printf("%s\n", str($obj));
     }
     $stack->push(box(2));
     $stack->push(box(4));
     $stack->push(box(6));
     printf("%s\n", str($stack));
     printf("Purging\n");
     $stack->purge();
     printf("%s\n", str($stack));
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:35,代码来源:AbstractStack.php


示例2: test

 /**
  * PriorityQueue test method.
  *
  * @param object IPriorityQueue $pqueue The queue to test.
  */
 public static function test(IPriorityQueue $pqueue)
 {
     printf("AbstractPriorityQueue test program.\n");
     printf("%s\n", str($pqueue));
     $pqueue->enqueue(box(3));
     $pqueue->enqueue(box(1));
     $pqueue->enqueue(box(4));
     $pqueue->enqueue(box(1));
     $pqueue->enqueue(box(5));
     $pqueue->enqueue(box(9));
     $pqueue->enqueue(box(2));
     $pqueue->enqueue(box(6));
     $pqueue->enqueue(box(5));
     $pqueue->enqueue(box(4));
     printf("%s\n", str($pqueue));
     printf("Using reduce\n");
     $pqueue->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), '');
     printf("Using foreach\n");
     foreach ($pqueue as $obj) {
         printf("%s\n", str($obj));
     }
     printf("Dequeueing\n");
     while (!$pqueue->isEmpty()) {
         $obj = $pqueue->dequeueMin();
         printf("%s\n", str($obj));
     }
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:32,代码来源:AbstractPriorityQueue.php


示例3: flush

 /**
  * @see Log
  */
 public function flush($logs, $id, $stdout)
 {
     foreach ($logs as $log) {
         try {
             $vars = $options = array();
             foreach (module_const_array('params') as $param) {
                 list($name, $value) = array_map('trim', explode(',', $param, 2));
                 $vars[$name] = $value;
             }
             $vars['level'] = $log->fm_level();
             $value = $log->value();
             if (is_array($value)) {
                 $value = array_shift($value);
             }
             switch ($log->fm_level()) {
                 case 'error':
                 case 'warn':
                 case 'info':
                     $vars['priv'] = 1;
                     $vars['message'] = sprintf("%s:%s %s", pathinfo($log->file(), PATHINFO_FILENAME), $log->line(), str($value));
                     break;
             }
             if (isset($vars['message'])) {
                 $data = http_build_query($vars);
                 $header = array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($data));
                 $options = array('http' => array('method' => 'POST', 'header' => implode("\r\n", $header), 'content' => $data));
                 file_get_contents(module_const('url'), false, stream_context_create($options));
             }
         } catch (Exception $e) {
         }
         // print(sprintf('console.%s("[%s:%d]",%s);',$log->fm_level(),$log->file(),$log->line(),str_replace("\n","\\n",Text::to_json($log->value()))));
     }
 }
开发者ID:nequal,项目名称:Openpear,代码行数:36,代码来源:LogIrcNotice.php


示例4: main

 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 3.\n");
     $status = 0;
     $p1 = new PolynomialAsOrderedList();
     $p1->add(new Term(4.5, 5));
     $p1->add(new Term(3.2, 14));
     printf("%s\n", str($p1));
     $p1->differentiate();
     printf("%s\n", str($p1));
     $p2 = new PolynomialAsSortedList();
     $p2->add(new Term(7.8, 0));
     $p2->add(new Term(1.6, 14));
     $p2->add(new Term(9.999000000000001, 27));
     printf("%s\n", str($p2));
     $p2->differentiate();
     printf("%s\n", str($p2));
     $p3 = new PolynomialAsSortedList();
     $p3->add(new Term(0.6, 13));
     $p3->add(new Term(-269.973, 26));
     $p3->add(new Term(1000, 1000));
     printf("%s\n", str($p3));
     printf("%s\n", str($p2->plus($p3)));
     return $status;
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:31,代码来源:Application3.php


示例5: test

 /**
  * Search tree test program.
  *
  * @param object ISearchTree $tree The tree to test.
  */
 public static function test(ISearchTree $tree)
 {
     printf("AbstractSearchTree test program.\n");
     printf("%s\n", str($tree));
     for ($i = 1; $i <= 8; ++$i) {
         $tree->insert(box($i));
     }
     printf("%s\n", str($tree));
     printf("Breadth-First traversal\n");
     $tree->breadthFirstTraversal(new PrintingVisitor(STDOUT));
     printf("Preorder traversal\n");
     $tree->depthFirstTraversal(new PreOrder(new PrintingVisitor(STDOUT)));
     printf("Inorder traversal\n");
     $tree->depthFirstTraversal(new InOrder(new PrintingVisitor(STDOUT)));
     printf("Postorder traversal\n");
     $tree->depthFirstTraversal(new PostOrder(new PrintingVisitor(STDOUT)));
     printf("Using foreach\n");
     foreach ($tree as $obj) {
         printf("%s\n", str($obj));
     }
     printf("Using reduce\n");
     $tree->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), '');
     printf("Using accept\n");
     $tree->accept(new ReducingVisitor(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), ''));
     printf("Withdrawing 4\n");
     $obj = $tree->find(box(4));
     try {
         $tree->withdraw($obj);
         printf("%s\n", str($tree));
     } catch (Exception $e) {
         printf("Caught %s\n", $e->getMessage());
     }
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:38,代码来源:AbstractSearchTree.php


示例6: test

 /**
  * OrderedList test method.
  *
  * @param object IOrderedList $list The list to test.
  */
 public static function test(IOrderedList $list)
 {
     printf("AbstractOrderedList test program.\n");
     $list->insert(box(1));
     $list->insert(box(2));
     $list->insert(box(3));
     $list->insert(box(4));
     printf("%s\n", str($list));
     $obj = $list->find(box(2));
     $list->withdraw($obj);
     printf("%s\n", str($list));
     $position = $list->findPosition(box(3));
     $position->insertAfter(box(5));
     printf("%s\n", str($list));
     $position->insertBefore(box(6));
     printf("%s\n", str($list));
     $position->withdraw();
     printf("%s\n", str($list));
     printf("Using foreach\n");
     foreach ($list as $obj) {
         printf("%s\n", str($obj));
     }
     printf("Using reduce\n");
     $list->reduce(create_function('$sum,$obj', 'printf("%s\\n", str($obj));'), '');
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:30,代码来源:AbstractOrderedList.php


示例7: main

 /**
  * Main program.
  *
  * @param array $args Command-line arguments.
  * @return integer Zero on success; non-zero on failure.
  */
 public static function main($args)
 {
     printf("Application program number 6. (expression tree)\n");
     $status = 0;
     $expression = ExpressionTree::parsePostfix(STDIN);
     printf("%s\n", str($expression));
     return $status;
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:14,代码来源:Application6.php


示例8: set_charge

 public function set_charge(OpenpearCharge $charge)
 {
     $this->handlename($charge->maintainer()->name());
     $this->name(str($charge->maintainer()));
     $this->mail($charge->maintainer()->mail());
     $this->role($charge->role());
     return $this;
 }
开发者ID:nequal,项目名称:Openpear,代码行数:8,代码来源:PackageProjectorConfigMaintainer.php


示例9: test

 /**
  * Digraph test method.
  *
  * @param object IDigraph $g The digraph to test.
  */
 public static function test(IDigraph $g)
 {
     printf("Digraph test program.\n");
     AbstractGraph::Test($g);
     printf("TopologicalOrderTraversal\n");
     $g->topologicalOrderTraversal(new PrintingVisitor(STDOUT));
     printf("isCyclic returns %s\n", str($g->isCyclic()));
     printf("isStronglyConnected returns %s\n", str($g->isStronglyConnected()));
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:14,代码来源:AbstractDigraph.php


示例10: platform_new

function platform_new($nom)
{
    try {
        $result = sql_do('INSERT INTO ' . DB_PREF . '_platforms (name_pf) VALUES (\'' . str($nom) . '\')');
    } catch (DatabaseException $e) {
        return 0;
    }
    return sql_last_id();
}
开发者ID:BackupTheBerlios,项目名称:igoan-svn,代码行数:9,代码来源:Platform.class.php


示例11: testCanBeInstantiated

 public function testCanBeInstantiated()
 {
     $string = new StringBuffer('string');
     $this->assertEquals('string', $string->get());
     $string = new StringBuffer(new TestToStringObject());
     $this->assertEquals('string', $string->get());
     $string = str('string');
     $this->assertEquals('string', $string->get());
 }
开发者ID:laraplus,项目名称:string,代码行数:9,代码来源:SupportStringBufferTest.php


示例12: license_new

function license_new($nom, $term)
{
    try {
        sql_do('INSERT INTO ' . DB_PREF . '_licenses (name_lic,terms) VALUES (\'' . str($nom) . '\',\'' . str($term) . '\')');
    } catch (DatabaseException $e) {
        return 0;
    }
    return sql_last_id();
}
开发者ID:BackupTheBerlios,项目名称:igoan-svn,代码行数:9,代码来源:License.class.php


示例13: language_new

function language_new($nom)
{
    try {
        sql_do('INSERT INTO ' . DB_PREF . '_languages (name_lang) VALUES (\'' . str($nom) . '\')');
    } catch (DatabaseException $e) {
        return 0;
    }
    return sql_last_id();
}
开发者ID:BackupTheBerlios,项目名称:igoan-svn,代码行数:9,代码来源:Language.class.php


示例14: license_new

function license_new($nom, $term)
{
    $id_lic = pick_id('licenses_id_lic_seq');
    try {
        sql_do('INSERT INTO licenses (id_lic,name_lic,terms) VALUES (\'' . int($id_lic) . '\',\'' . str($nom) . '\',\'' . str($term) . '\')');
    } catch (DatabaseException $e) {
        return 0;
    }
    return $id_lic;
}
开发者ID:BackupTheBerlios,项目名称:igoan,代码行数:10,代码来源:License.class.php


示例15: language_new

function language_new($nom)
{
    $id_lang = pick_id('languages_id_lang_seq');
    try {
        sql_do('INSERT INTO languages (id_lang,name_lang) VALUES (' . int($id_lang) . ',\'' . str($nom) . '\')');
    } catch (DatabaseException $e) {
        return 0;
    }
    return $id_lang;
}
开发者ID:BackupTheBerlios,项目名称:igoan-svn,代码行数:10,代码来源:Language.class.php


示例16: str

 function str($str)
 {
     if (is_array($str)) {
         foreach ($str as $k => $v) {
             $str[$k] = str($v);
         }
     } else {
         $str = stripcslashes($str);
     }
     return $str;
 }
开发者ID:hxfsc,项目名称:hxfsc,代码行数:11,代码来源:global.php


示例17: _getOrderNum

 protected function _getOrderNum()
 {
     $str = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
     $str = str(str_shuffle($str), 0, 12);
     $sn = date('Ymd') . $str;
     $orders = M('Orders');
     $where = array('order_sn' => $sn);
     $res = $orders->where($where)->find();
     echo $orders->getLastSql();
     die;
 }
开发者ID:kevinchfe,项目名称:haya,代码行数:11,代码来源:OrderController.class.php


示例18: __after_save__

 protected function __after_save__()
 {
     self::recount_favorites($this->package_id());
     C($this)->commit();
     $timeline = new OpenpearTimeline();
     $timeline->subject(sprintf('<a href="%s">%s</a> <span class="hl">liked</span> <a href="%s">%s</a>', url('maintainer/' . $this->maintainer()->name()), R(Templf)->htmlencode(str($this->maintainer())), url('package/' . $this->package()->name()), $this->package()->name()));
     $timeline->description(sprintf('<a href="%s">%s</a>: latest %s. %d fans.', url('package/' . $this->package()->name()), $this->package()->name(), $this->package()->latest_release()->fm_version(), C(OpenpearFavorite)->find_count(Q::eq('package_id', $this->package_id()))));
     $timeline->type('favorite');
     $timeline->package_id($this->package_id());
     $timeline->maintainer_id($this->maintainer_id());
     $timeline->save();
 }
开发者ID:nequal,项目名称:Openpear,代码行数:12,代码来源:OpenpearFavorite.php


示例19: str

function str($arr)
{
    static $temp = array();
    foreach ($arr as $k => $v) {
        $temp[] = $k;
        if (!empty($v)) {
            str($v);
        } else {
            $str = implode(">", $temp);
            echo $str . "\n";
        }
        array_pop($temp);
    }
}
开发者ID:xzungshao,项目名称:iphp,代码行数:14,代码来源:tstack.php


示例20: test

 /**
  * SortedList test method.
  *
  * @param object ISortedList $list The list to test.
  */
 public static function test(ISortedList $list)
 {
     printf("AbstractSortedList test program.\n");
     $list->insert(box(4));
     $list->insert(box(3));
     $list->insert(box(2));
     $list->insert(box(1));
     printf("%s\n", str($list));
     $obj = $list->find(box(2));
     $list->withdraw($obj);
     printf("%s\n", str($list));
     printf("Using foreach\n");
     foreach ($list as $obj) {
         printf("%s\n", str($obj));
     }
 }
开发者ID:EdenChan,项目名称:Instances,代码行数:21,代码来源:AbstractSortedList.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP str2arr函数代码示例发布时间:2022-05-23
下一篇:
PHP store_steps函数代码示例发布时间: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