当前位置: 首页>>代码示例>>PHP>>正文


PHP read函数代码示例

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


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

示例1: select_account

function select_account()
{
    $accounts = get_auth_keys();
    //Show Account List
    if (count($accounts) < 1) {
        println("Please authenticate account.");
        println("eg) php auth_request.php");
        exit(1);
    }
    println("Please select the account.");
    foreach ($accounts as $screen_name => $token) {
        println(sprintf("@%s", $screen_name));
    }
    //input screen_name
    echo ">@";
    while (true) {
        //input
        $screen_name = strtolower(trim(read()));
        //authenticate user check
        if (!array_key_exists($screen_name, $accounts)) {
            println("Please select the authenticated account");
            echo ">@";
            continue;
        }
        break;
    }
    return ["screen_name" => $screen_name, "access_token" => $accounts[$screen_name]["access_token_key"], "access_token_secret" => $accounts[$screen_name]["access_token_secret"]];
}
开发者ID:suzutan,项目名称:twitter-namechecker,代码行数:28,代码来源:_init.php

示例2: hydrate_model

function hydrate_model($file)
{
    if (is_file($file) && strpos($file, '.php')) {
        preg_match_all('/class\\s(\\S+)\\s/', read($file), $match);
        require $file;
        foreach ($match[1] as $klass) {
            $re = new \ReflectionClass($klass);
            switch ($re->getParentClass()->getName()) {
                case 'Servant\\Mapper\\Database':
                    status('hydrate', $file);
                    $dsn = option('database.' . $klass::CONNECTION);
                    $db = \Grocery\Base::connect($dsn);
                    $columns = $klass::columns();
                    $indexes = $klass::indexes();
                    if (!isset($db[$klass::table()])) {
                        $db[$klass::table()] = $columns;
                    }
                    \Grocery\Helpers::hydrate($db[$klass::table()], $columns, $indexes);
                    break;
                case 'Servant\\Mapper\\MongoDB':
                    status('hydrate', $file);
                    $dsn_string = \Servant\Config::get($klass::CONNECTION);
                    $database = substr($dsn_string, strrpos($dsn_string, '/') + 1);
                    $mongo = $dsn_string ? new \Mongo($dsn_string) : new \Mongo();
                    $db = $mongo->{$database ?: 'default'};
                    \Servant\Helpers::reindex($db->{$klass::table()}, $klass::indexes());
                    break;
                default:
                    break;
            }
        }
    }
}
开发者ID:hbnro,项目名称:habanero,代码行数:33,代码来源:functions.php

示例3: __construct

 function __construct()
 {
     /* --------------------------------------------------------------
      * Swap information
      * -------------------------------------------------------------- */
     @preg_match_all('/^([^:]+)\\:\\s+(\\d+)\\s*(?:k[bB])?\\s*/m', read('/proc/meminfo'), $matches, PREG_SET_ORDER);
     if ($matches) {
         foreach ($matches as $item) {
             switch (strtolower($item[1])) {
                 case 'swaptotal':
                     $this->total = $item[2];
                     break;
                 case 'swapfree':
                     $this->free = $item[2];
                     break;
             }
         }
         if ($this->total) {
             $this->used = $this->total - $this->free;
             $this->percentage = $this->used / $this->total * 100;
         } else {
             $this->used = 0;
             $this->percentage = 0;
         }
     }
 }
开发者ID:cmmora,项目名称:dashboard,代码行数:26,代码来源:swap.php

示例4: readon

function readon($server)
{
    echo "<span id=connect>Connected.<br></span>";
    while ($GLOBALS['connected']) {
        $line = read($server);
        $line = trim($line);
        if ($line != "") {
            if (strpos($line, ":!:ping:!:") !== false) {
                write(":!:pong:!:", $server);
            } else {
                if (strpos($line, ":!:hangup:!:") !== false) {
                    $GLOBALS['connected'] = false;
                } else {
                    if (strpos($line, ":!:players:!:") !== false) {
                        disPlayers(substr($line, 13));
                    } else {
                        if (strpos($line, ":!:info:!:") !== false) {
                            echo "<span id=info>" . substr($line, 10) . "</span><br>";
                        } else {
                            echo "<span id=gos>" . $line . "</span><br>";
                        }
                    }
                }
            }
        }
        checkSql($server);
        ob_flush();
        flush();
        echo " <script language=javascript>window.scroll(0,50000);</script>";
        sleep(1);
    }
}
开发者ID:BearFather,项目名称:GosLink2-WebSocket,代码行数:32,代码来源:output.php

示例5: retornaPosts

function retornaPosts($cond = null)
{
    if ($cond) {
        $post = read('post', $cond);
    } else {
        $post = read('post');
    }
    return $post;
}
开发者ID:BrunoPastorello,项目名称:blog_video_aulas_cad,代码行数:9,代码来源:post_blog.php

示例6: setViews

function setViews($topicoId)
{
    $topicoId = mysql_real_escape_string($topicoId);
    $readArtigo = read('up_posts', "WHERE id = '{$topicoId}'");
    foreach ($readArtigo as $artigo) {
    }
    $views = $artigo['visitas'];
    $views = $views + 1;
    $dataViews = array('visitas' => $views);
    update('up_posts', $dataViews, "id = '{$topicoId}'");
}
开发者ID:BrunoPastorello,项目名称:php-estudos,代码行数:11,代码来源:setSis.php

示例7: read_yn

/**
 * Creates Yes/No question dialog. It waits until user types either Y or N (non-case sensitive)
 * 
 * @param String $q the question
 *
 * @return String answer
 **/
function read_yn($q)
{
    $ans = '';
    while (1) {
        writeln($q . " [Y/N]");
        $ans = read();
        if (strtoupper($ans) == 'Y' || strtoupper($ans) == 'N') {
            break;
        }
    }
    return $ans;
}
开发者ID:laiello,项目名称:pef,代码行数:19,代码来源:cli.lib.php

示例8: setViews

function setViews($topicoId)
{
    $con = mysqli_connect(HOST, USER, PASS, DBAS) or die(mysqli_error($con) . "Não foi possível fazer a conexão com o sistema");
    $topicoId = mysqli_real_escape_string($con, $topicoId);
    $readArtigo = read('post', "WHERE id = '{$topicoId}'");
    foreach ($readArtigo as $artigo) {
    }
    $views = $artigo['visitas'];
    $views = $views + 1;
    $dataViews = array('visitas' => $views);
    update('post', $dataViews, " WHERE id = '{$topicoId}'");
}
开发者ID:wilsonazer,项目名称:santodaime,代码行数:12,代码来源:setSis.php

示例9: write

function write($newtext, $fn, $search)
{
    $file = file_get_contents($fn);
    $arr = explode($search . ':', $file);
    $oldtext = explode(";", $arr[1]);
    if ($oldtext[0] == "") {
        $oldtext[0] = " ";
        $str = str_replace(substr($oldtext[0], 0, 0), $newtext, $file);
    }
    $str = str_replace($oldtext[0], $newtext, $file);
    file_put_contents($fn, $str);
    return read($fn, $search);
}
开发者ID:Cjones90,项目名称:Legacy-Projects,代码行数:13,代码来源:includes.php

示例10: controller

function controller()
{
    $id = $_REQUEST["id"];
    $action = $_REQUEST["action"];
    switch ($id) {
        case "recommand":
            include "model/recommand_data.php";
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "news":
            include "model/news_data.php";
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "local":
            include 'model/local_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "image":
            include 'model/image_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        case "entertainment":
            include 'model/entertainment_data.php';
            if ($action == 'upload') {
                add($_REQUEST, $_FILES);
            } else {
                read();
            }
            break;
        default:
            break;
    }
}
开发者ID:albertmjy,项目名称:H5_Work,代码行数:49,代码来源:controller.php

示例11: __construct

 function __construct()
 {
     /* --------------------------------------------------------------
      * CPU load
      * -------------------------------------------------------------- */
     $parts = explode(" ", read('/proc/loadavg'));
     if ($parts) {
         $this->load = $parts[0];
         $this->load5 = $parts[1];
         $this->load15 = $parts[2];
     }
     /* --------------------------------------------------------------
      * CPU information
      * -------------------------------------------------------------- */
     $processors = preg_split('/\\s?\\n\\s?\\n/', read('/proc/cpuinfo'));
     if ($processors) {
         // only using first cpu for information
         $processor = reset($processors);
         $lines = explode("\n", $processor);
         foreach ($lines as $line) {
             list($key, $value) = explode(':', $line, 2);
             switch (strtolower(trim($key))) {
                 case 'processor':
                 case 'model name':
                     $this->name = $value;
                     break;
                 case 'clock':
                 case 'cpu mhz':
                     $this->frequency = $value;
                     break;
                 case 'bogomips':
                     if (!isset($this->frequency)) {
                         $this->frequency = $value;
                     }
                     break;
             }
         }
         $this->count = count($processors);
     }
     /* --------------------------------------------------------------
      * Raspberry Pi Temperature
      * -------------------------------------------------------------- */
     $temp = read('/sys/class/thermal/thermal_zone0/temp');
     if ($temp) {
         $this->temp = $temp / 1000;
     }
 }
开发者ID:cmmora,项目名称:dashboard,代码行数:47,代码来源:cpu.php

示例12: __construct

 function __construct()
 {
     /* --------------------------------------------------------------
      * Network adapters
      * -------------------------------------------------------------- */
     $lines = explode("\n", read('/proc/net/dev'));
     foreach ($lines as $line) {
         if (!strpos($line, ':')) {
             continue;
         }
         $parts = preg_split('/\\s+/', trim($line));
         $adapter = substr($parts[0], 0, -1);
         $state = read('/sys/class/net/' . $adapter . '/operstate');
         if ($state == 'unknown' || $state == '') {
             continue;
         }
         $this->{$adapter} = new stdClass();
         $this->{$adapter}->state = $state;
         $this->{$adapter}->speed = read('/sys/class/net/' . $adapter . '/speed');
         $this->{$adapter}->received = $parts[1];
         $this->{$adapter}->sent = $parts[9];
         $this->{$adapter}->total = $this->{$adapter}->sent + $this->{$adapter}->received;
         $this->{$adapter}->dropped = $parts[4] + $parts[12];
         $this->{$adapter}->errors = $parts[3] + $parts[11];
         /* --------------------------------------------------------------
          * ifconfig
          * -------------------------------------------------------------- */
         $ifconfig = array();
         exec('/sbin/ifconfig ' . $adapter, $ifconfig);
         if ($ifconfig) {
             foreach ($ifconfig as $line) {
                 if (preg_match('/inet\\saddr:\\s*(\\S*)/i', $line, $matches)) {
                     $this->{$adapter}->ip = $matches[1];
                 } else {
                     if (preg_match('/inet6\\saddr:\\s*(\\S*)/i', $line, $matches)) {
                         $this->{$adapter}->ipv6 = $matches[1];
                     } else {
                         if (preg_match('/HWaddr\\s*(\\S*)/i', $line, $matches)) {
                             $this->{$adapter}->mac = $matches[1];
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:cmmora,项目名称:dashboard,代码行数:46,代码来源:network.php

示例13: show

function show(array $files, $context)
{
    foreach ($files as $file) {
        $data = read($file);
        $ok = phutil_is_utf8($data);
        if ($ok) {
            echo "OKAY";
        } else {
            echo "FAIL";
        }
        echo "  " . name($file) . "\n";
        if (!$ok) {
            $lines = explode("\n", $data);
            $len = count($lines);
            $map = array();
            $bad = array();
            foreach ($lines as $n => $line) {
                if (phutil_is_utf8($line)) {
                    continue;
                }
                $bad[$n] = true;
                for ($jj = max(0, $n - $context); $jj < min($len, $n + 1 + $context); $jj++) {
                    $map[$jj] = true;
                }
            }
            $width = strlen(max(array_keys($map)));
            // Set $last such that we print a newline on the first iteration thorugh
            // the loop.
            $last = -2;
            foreach ($map as $idx => $ignored) {
                if ($idx != $last + 1) {
                    printf("\n");
                }
                $last = $idx;
                $line = $lines[$idx];
                if (!empty($bad[$idx])) {
                    $line = show_problems($line);
                }
                printf("  % {$width}d  %s\n", $idx + 1, $line);
            }
            echo "\n";
        }
    }
    return 0;
}
开发者ID:rwray,项目名称:libphutil,代码行数:45,代码来源:utf8.php

示例14: __construct

 function __construct()
 {
     /* --------------------------------------------------------------
      * System uptime
      * -------------------------------------------------------------- */
     $output = read('/proc/uptime');
     list($seconds) = explode(' ', $output);
     $minutes = (int) $seconds / 60;
     $seconds = $seconds % 60;
     $hours = (int) $minutes / 60;
     $minutes = $minutes % 60;
     $days = (int) $hours / 24;
     $hours = $hours % 24;
     $this->days = floor($days);
     $this->hours = floor($hours);
     $this->minutes = floor($minutes);
     $this->seconds = floor($seconds);
 }
开发者ID:cmmora,项目名称:dashboard,代码行数:18,代码来源:uptime.php

示例15: index_action

 function index_action()
 {
     if (!checkfile('plugins', 0)) {
         $plugins = $this->plugin->GetPage(array('isshow' => 0));
         foreach ($plugins as $k => $v) {
             $v['isinstalled'] = 1;
             $pluginlist[] = $v;
         }
         $plugins = $this->_getAllPlugins();
         foreach ($plugins as $k => $v) {
             $v['isinstalled'] = 0;
             $pluginlist[] = $v;
         }
         write('plugins', $pluginlist);
     } else {
         $pluginlist = read('plugins');
     }
     include ROOT_PATH . '/views/admin/plugin.php';
 }
开发者ID:BGCX261,项目名称:zidan-kaka-oneplusone-svn-to-git,代码行数:19,代码来源:plugin.class.php


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