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


PHP addcslashes函数代码示例

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


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

示例1: toString

 /**
  * Create string representation
  *
  * @return  string
  */
 public function toString()
 {
     $args = array();
     if (isset($this->args)) {
         for ($j = 0, $a = sizeof($this->args); $j < $a; $j++) {
             if (is_array($this->args[$j])) {
                 $args[] = 'array[' . sizeof($this->args[$j]) . ']';
             } else {
                 if (is_object($this->args[$j])) {
                     $args[] = $this->qualifiedClassName(get_class($this->args[$j])) . '{}';
                 } else {
                     if (is_string($this->args[$j])) {
                         $display = str_replace('%', '%%', addcslashes(substr($this->args[$j], 0, min(FALSE === ($p = strpos($this->args[$j], "\n")) ? 0x40 : $p, 0x40)), ".."));
                         $args[] = '(0x' . dechex(strlen($this->args[$j])) . ")'" . $display . "'";
                     } else {
                         if (is_null($this->args[$j])) {
                             $args[] = 'NULL';
                         } else {
                             if (is_scalar($this->args[$j])) {
                                 $args[] = (string) $this->args[$j];
                             } else {
                                 if (is_resource($this->args[$j])) {
                                     $args[] = (string) $this->args[$j];
                                 } else {
                                     $args[] = '<' . gettype($this->args[$j]) . '>';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return sprintf("  at %s::%s(%s) [line %d of %s] %s\n", isset($this->class) ? $this->qualifiedClassName($this->class) : '<main>', isset($this->method) ? $this->method : '<main>', implode(', ', $args), $this->line, basename(isset($this->file) ? $this->file : __FILE__), $this->message);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:40,代码来源:StackTraceElement.class.php

示例2: search

 public function search(\GoRemote\Application $app, $query)
 {
     $searchQuery = '%' . addcslashes($query, "%_") . '%';
     //select * from jobs inner join companies using(companyid) inner join sources using(sourceid) where match(companies.name, sources.name, jobs.position, jobs.description) against ('php' IN NATURAL LANGUAGE MODE);
     $jobs = $app['db']->fetchAll("select jobs.*, unix_timestamp(jobs.dateadded) as dateadded_unixtime, companies.name as companyname, companies.url as companyurl, sources.name as sourcename, sources.url as sourceurl  from jobs \n        inner join companies using(companyid) \n        inner join sources using(sourceid) \n        where jobs.dateadded > UTC_TIMESTAMP() - INTERVAL 2 MONTH\n        and jobs.datedeleted=0 \n\tand jobs.position <> '' \n        and (\n            companies.name like ? or \n            jobs.position like ? or \n            jobs.description like ?\n            )\n        order by jobs.dateadded desc limit 80", [$searchQuery, $searchQuery, $searchQuery]);
     return $jobs;
 }
开发者ID:akhterwahab,项目名称:goremote.io,代码行数:7,代码来源:SearchModel.php

示例3: doConvert

 public static function doConvert(array $data, array $parent = array())
 {
     $output = '';
     foreach ($data as $k => $v) {
         $index = str_replace(' ', '-', $k);
         if (is_array($v)) {
             $sec = array_merge((array) $parent, (array) $index);
             $output .= PHP_EOL . '[' . join('.', $sec) . ']' . PHP_EOL;
             $output .= self::doConvert($v, $sec);
         } else {
             $output .= "{$index}=";
             if (is_numeric($v) || is_float($v)) {
                 $output .= "{$v}";
             } elseif (is_bool($v)) {
                 $output .= $v === true ? 1 : 0;
             } elseif (is_string($v)) {
                 $output .= "'" . addcslashes($v, "'") . "'";
             } else {
                 $output .= "{$v}";
             }
             $output .= PHP_EOL;
         }
     }
     return $output;
 }
开发者ID:atelierspierrot,项目名称:library,代码行数:25,代码来源:Array2INI.php

示例4: set

 public function set($config_id, $data)
 {
     if (!$data || !is_array($data)) {
         throw new Zend_Exception('config data type error');
     }
     $content = "<?php\n\n";
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             $content .= "\$config['{$key}'] = " . var_export($val, true) . ";";
         } else {
             if (is_bool($val)) {
                 $content .= "\$config['{$key}'] = " . ($val ? 'true' : 'false') . ";";
             } else {
                 $content .= "\$config['{$key}'] = '" . addcslashes($val, "'") . "';";
             }
         }
         $content .= "\r\n";
     }
     $config_path = AWS_PATH . 'config/' . $config_id . '.php';
     $fp = @fopen($config_path, "w");
     @chmod($config_path, 0777);
     $fwlen = @fwrite($fp, $content);
     @fclose($fp);
     return $fwlen;
 }
开发者ID:Vizards,项目名称:HeavenSpree,代码行数:25,代码来源:config.php

示例5: format

    /**
     * {@inheritDoc}
     */
    public function format($string)
    {
        static $format = <<<EOF
package main

import "fmt"
import "github.com/russross/blackfriday"

func main() {
    input := []byte("%s")
    output := blackfriday.MarkdownCommon(input)
    fmt.Printf(string(output[:]))
}
EOF;
        $input = tempnam(sys_get_temp_dir(), 'fabricius_blackfriday');
        $input .= '.go';
        file_put_contents($input, sprintf($format, addcslashes($string, "\n\"")));
        $pb = new ProcessBuilder(array($this->goBin, 'run', $input));
        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);
        if (0 !== $code) {
            $message = sprintf("An error occurred while running:\n%s", $proc->getCommandLine());
            $errorOutput = $proc->getErrorOutput();
            if (!empty($errorOutput)) {
                $message .= "\n\nError Output:\n" . str_replace("\r", '', $errorOutput);
            }
            $output = $proc->getOutput();
            if (!empty($output)) {
                $message .= "\n\nOutput:\n" . str_replace("\r", '', $output);
            }
            throw new RuntimeException($message);
        }
        return $proc->getOutput();
    }
开发者ID:fabricius,项目名称:fabricius,代码行数:38,代码来源:MarkdownBlackFridayHandler.php

示例6: render_comment_json

function render_comment_json($subject, $zid, $time, $cid, $body)
{
    global $can_moderate;
    global $auth_zid;
    $score = get_comment_score($cid);
    $rid = -1;
    if ($can_moderate) {
        $row = run_sql("select rid from comment_vote where cid = ? and zid = ?", array($cid, $auth_zid));
        if (count($row) == 0) {
            $rid = 0;
        } else {
            $rid = $row[0]["rid"];
        }
    }
    $s = "\$level{\n";
    $s .= "\$level\t\"cid\": {$cid},\n";
    $s .= "\$level\t\"zid\": \"{$zid}\",\n";
    $s .= "\$level\t\"time\": {$time},\n";
    $s .= "\$level\t\"score\": \"{$score}\",\n";
    $s .= "\$level\t\"rid\": {$rid},\n";
    $s .= "\$level\t\"subject\": \"" . addcslashes($subject, "\\\"") . "\",\n";
    $s .= "\$level\t\"comment\": \"" . addcslashes($body, "\\\"") . "\",\n";
    $s .= "\$level\t\"reply\": [\n";
    return $s;
}
开发者ID:scarnago,项目名称:pipecode,代码行数:25,代码来源:render.php

示例7: find

 /**
  * {@inheritdoc}
  */
 public function find($ip, $url, $limit, $method, $start = NULL, $end = NULL)
 {
     $select = $this->database->select('webprofiler', 'wp', ['fetch' => \PDO::FETCH_ASSOC]);
     if (NULL === $start) {
         $start = 0;
     }
     if (NULL === $end) {
         $end = time();
     }
     if ($ip = preg_replace('/[^\\d\\.]/', '', $ip)) {
         $select->condition('ip', '%' . $this->database->escapeLike($ip) . '%', 'LIKE');
     }
     if ($url) {
         $select->condition('url', '%' . $this->database->escapeLike(addcslashes($url, '%_\\')) . '%', 'LIKE');
     }
     if ($method) {
         $select->condition('method', $method);
     }
     if (!empty($start)) {
         $select->condition('time', $start, '>=');
     }
     if (!empty($end)) {
         $select->condition('time', $end, '<=');
     }
     $select->fields('wp', ['token', 'ip', 'method', 'url', 'time', 'parent']);
     $select->orderBy('time', 'DESC');
     $select->range(0, $limit);
     return $select->execute()->fetchAllAssoc('token');
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:32,代码来源:DatabaseProfilerStorage.php

示例8: usesubmit

 function usesubmit()
 {
     global $_G;
     $list = $uids = array();
     $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10;
     $limit = $num + 20;
     $giftMagicID = C::t('common_magic')->fetch_by_identifier('gift');
     $mid = $giftMagicID['available'] ? intval($giftMagicID['magicid']) : 0;
     if ($mid) {
         foreach (C::t('common_magiclog')->fetch_all_by_magicid_action_uid($mid, 2, $_G['uid'], 0, $limit) as $value) {
             $uids[] = intval($value['uid']);
         }
     }
     if ($uids) {
         $counter = 0;
         $members = C::t('common_member')->fetch_all($uids);
         foreach (C::t('common_member_field_home')->fetch_all($uids) as $uid => $value) {
             $value = array_merge($members[$uid], $value);
             $info = !empty($value['magicgift']) ? unserialize($value['magicgift']) : array();
             if (!empty($info['left']) && (empty($info['receiver']) || !in_array($_G['uid'], $info['receiver']))) {
                 $value['avatar'] = addcslashes(avatar($uid, 'small'), "'");
                 $list[$uid] = $value;
                 $counter++;
                 if ($counter >= $num) {
                     break;
                 }
             }
         }
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']);
     $op = 'show';
     include template('home/magic_detector');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:34,代码来源:magic_detector.php

示例9: init

 /**
  * init
  *
  * Establishes base settings for making recommendations.
  *
  * @param string                            $settings Settings from config.ini
  * @param \VuFind\RecordDriver\AbstractBase $driver   Record driver object
  *
  * @return void
  */
 public function init($settings, $driver)
 {
     // If we have query parts, we should try to find related records:
     $parts = $this->getQueryParts($driver);
     if (!empty($parts)) {
         // Limit the number of parts based on the boolean clause limit:
         $sm = $this->getSearchManager();
         $params = $sm->setSearchClassId('Solr')->getParams();
         $limit = $params->getQueryIDLimit();
         if (count($parts) > $limit) {
             $parts = array_slice($parts, 0, $limit);
         }
         // Assemble the query parts and filter out current record if it comes
         // from the Solr index.:
         $query = '(' . implode(' OR ', $parts) . ')';
         if ($driver->getResourceSource() == 'VuFind') {
             $query .= ' NOT id:"' . addcslashes($driver->getUniqueID(), '"') . '"';
         }
         // Perform the search and return either results or an error:
         $params->setLimit(5);
         $params->setOverrideQuery($query);
         $result = $sm->setSearchClassId('Solr')->getResults($params);
         $this->results = $result->getResults();
     }
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:35,代码来源:Editions.php

示例10: ToSql

 public static function ToSql($field, $oper, $val)
 {
     // we need here more advanced checking using the type of the field - i.e. integer, string, float
     switch ($field) {
         case 'id':
             return intval($val);
             break;
         case 'amount':
         case 'tax':
         case 'total':
             return floatval($val);
             break;
         default:
             //mysql_real_escape_string is better
             if ($oper == 'bw' || $oper == 'bn') {
                 return "'" . addslashes($val) . "%'";
             } else {
                 if ($oper == 'ew' || $oper == 'en') {
                     return "'%" . addcslashes($val) . "'";
                 } else {
                     if ($oper == 'cn' || $oper == 'nc') {
                         return "'%" . addslashes($val) . "%'";
                     } else {
                         return "'" . addslashes($val) . "'";
                     }
                 }
             }
     }
 }
开发者ID:deanstalker,项目名称:phpVMS,代码行数:29,代码来源:jqgrid.class.php

示例11: gridAction

 /**
  * @Route("/grid", name="lc_admin_person_grid")
  * @Template()
  */
 public function gridAction(Request $request)
 {
     $form = $this->createForm(new PersonFilterFormType());
     $form->handleRequest($request);
     $result['grid'] = null;
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $sql = $em->createQueryBuilder();
         $sql->select('u');
         $sql->from('PROCERGSLoginCidadaoCoreBundle:Person', 'u');
         $sql->where('1=1');
         $parms = $form->getData();
         if (isset($parms['username'][0])) {
             $sql->andWhere('u.cpf like ?1 or LowerUnaccent(u.username) like LowerUnaccent(?1) or LowerUnaccent(u.email) like LowerUnaccent(?1) or LowerUnaccent(u.firstName) like LowerUnaccent(?1) or LowerUnaccent(u.surname) like LowerUnaccent(?1)');
             $sql->setParameter('1', '%' . addcslashes($parms['username'], '\\%_') . '%');
         }
         $sql->addOrderBy('u.id', 'desc');
         $grid = new GridHelper();
         $grid->setId('person-grid');
         $grid->setPerPage(5);
         $grid->setMaxResult(5);
         $grid->setQueryBuilder($sql);
         $grid->setInfiniteGrid(true);
         $grid->setRoute('lc_admin_person_grid');
         $grid->setRouteParams(array($form->getName()));
         return array('grid' => $grid->createView($request));
     }
     return $result;
 }
开发者ID:hacklabr,项目名称:login-cidadao,代码行数:33,代码来源:PersonController.php

示例12: searchkey

function searchkey($keyword, $field, $returnsrchtxt = 0)
{
    $srchtxt = '';
    if ($field && $keyword) {
        if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
            $andor = ' AND ';
            $keywordsrch = '1';
            $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
        } else {
            $andor = ' OR ';
            $keywordsrch = '0';
            $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
        }
        $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
        $srchtxt = $returnsrchtxt ? $keyword : '';
        foreach (explode('+', $keyword) as $text) {
            $text = trim(daddslashes($text));
            if ($text) {
                $keywordsrch .= $andor;
                $keywordsrch .= str_replace('{text}', $text, $field);
            }
        }
        $keyword = " AND ({$keywordsrch})";
    }
    return $returnsrchtxt ? array($srchtxt, $keyword) : $keyword;
}
开发者ID:lemonstory,项目名称:bbs,代码行数:26,代码来源:function_search.php

示例13: process

 /**
  * @param resource $pipe
  * @since Method available since Release 3.5.12
  */
 protected function process($pipe, $job)
 {
     if (!($this->tempFile = tempnam(sys_get_temp_dir(), 'PHPUnit')) || file_put_contents($this->tempFile, $job) === FALSE) {
         throw new PHPUnit_Framework_Exception('Unable to write temporary files for process isolation.');
     }
     fwrite($pipe, "<?php require_once '" . addcslashes($this->tempFile, "'") . "'; ?>");
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:11,代码来源:Windows.php

示例14: toXmlValue

 private function toXmlValue($a_key, $a_value)
 {
     switch (gettype($a_value)) {
         default:
             return makePair($a_key, $a_value);
         case 'string':
             if (preg_match("/\\n\\r\\t/i", $a_value)) {
                 return $this->makePair($a_key, '<![CDATA[' . $a_value . ']]>');
             }
             return $this->makePair($a_key, addcslashes($a_value, "\n\r\t\""));
         case 'array':
             $o = null;
             foreach ($a_value as $k => $v) {
                 $o .= $this->toXmlValue($k, $v);
             }
             return $this->makePair($a_key, $o);
         case 'object':
             $o = null;
             foreach (get_object_vars($a_value) as $k => $v) {
                 $o .= $this->toXmlValue($k, $v);
             }
             return $this->makePair($a_key, $o);
     }
     return null;
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:25,代码来源:xmlencoder.php

示例15: objectToString

 /**
  * Converts an object into a php class string.
  * - NOTE: Only one depth level is supported.
  *
  * @param   object  $object  Data Source Object
  * @param   array   $params  Parameters used by the formatter
  *
  * @return  string  Config class formatted string
  *
  * @since   1.0
  */
 public function objectToString($object, $params = array())
 {
     // Build the object variables string
     $vars = '';
     foreach (get_object_vars($object) as $k => $v) {
         if (is_scalar($v)) {
             $vars .= "\tpublic \$" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
         } elseif (is_array($v) || is_object($v)) {
             $vars .= "\tpublic \$" . $k . " = " . $this->getArrayString((array) $v) . ";\n";
         }
     }
     $str = "<?php\n";
     // If supplied, add a namespace to the class object
     if (isset($params['namespace']) && $params['namespace'] != '') {
         $str .= "namespace " . $params['namespace'] . ";\n\n";
     }
     $str .= "class " . $params['class'] . " {\n";
     $str .= $vars;
     $str .= "}";
     // Use the closing tag if it not set to false in parameters.
     if (!isset($params['closingtag']) || $params['closingtag'] !== false) {
         $str .= "\n?>";
     }
     return $str;
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:36,代码来源:Php.php


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