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

PHP explode函数代码示例

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

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



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

示例1: partial

 public function partial($partial, $__time = false, $params = null, $group = 'kumbia.partials')
 {
     //        if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
     //            return;
     //        }
     //Verificando el partials en el dir app
     $__file = $this->viewPath . "/_shared/partials/{$partial}.phtml";
     //        if (!is_file($__file)) {
     //            //Verificando el partials en el dir core
     //            $__file = CORE_PATH . "views/partials/$partial.phtml";
     //        }
     if ($params) {
         if (is_string($params)) {
             $params = Util::getParams(explode(',', $params));
         }
         // carga los parametros en el scope
         extract($params, EXTR_OVERWRITE);
     }
     // carga la vista parcial
     if (!(include $__file)) {
         throw new \Exception('Vista Parcial "' . $__file . '" no se encontro');
     }
     // se guarda en la cache de ser requerido
     //        if (PRODUCTION && $__time) {
     //            Cache::driver()->end();
     //        }
 }
开发者ID:Ashrey,项目名称:kumbia_pimple,代码行数:27,代码来源:View.php


示例2: inet6_expand

/**
 * Expand an IPv6 Address
 *
 * This will take an IPv6 address written in short form and expand it to include all zeros. 
 *
 * @param  string  $addr A valid IPv6 address
 * @return string  The expanded notation IPv6 address
 */
function inet6_expand($addr)
{
    /* Check if there are segments missing, insert if necessary */
    if (strpos($addr, '::') !== false) {
        $part = explode('::', $addr);
        $part[0] = explode(':', $part[0]);
        $part[1] = explode(':', $part[1]);
        $missing = array();
        for ($i = 0; $i < 8 - (count($part[0]) + count($part[1])); $i++) {
            array_push($missing, '0000');
        }
        $missing = array_merge($part[0], $missing);
        $part = array_merge($missing, $part[1]);
    } else {
        $part = explode(":", $addr);
    }
    // if .. else
    /* Pad each segment until it has 4 digits */
    foreach ($part as &$p) {
        while (strlen($p) < 4) {
            $p = '0' . $p;
        }
    }
    // foreach
    unset($p);
    /* Join segments */
    $result = implode(':', $part);
    /* Quick check to make sure the length is as expected */
    if (strlen($result) == 39) {
        return $result;
    } else {
        return false;
    }
    // if .. else
}
开发者ID:samburney,项目名称:pdns-backend-phpautoreverse,代码行数:43,代码来源:ipv6_functions.php


示例3: ur_questions

 /**
  * @throws \PhpOffice\PhpWord\Exception\Exception
  * Создание word для юр вопросов
  */
 public static function ur_questions($row)
 {
     $user = User::findOne(\Yii::$app->user->identity->id);
     $file = \Yii::$app->basePath . '/temp/ur_questions/' . $row['qid'] . '.docx';
     $template = \Yii::$app->basePath . '/temp/ur_questions/Template.docx';
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template);
     // Variables on different parts of document
     $row['question'] = str_replace("\n", "<w:br/>", $row['question']);
     //Для пробелов
     $templateProcessor->setValue('vopros', $row['question']);
     $templateProcessor->setValue('date', date("d.m.Y"));
     $templateProcessor->setValue('ur_name', $row['uname']);
     $templateProcessor->setValue('ur_ruk', $row['contact_face']);
     $templateProcessor->setValue('ur_phone', $row['contact_phone']);
     $templateProcessor->setValue('ur_mail', $row['contact_mail']);
     $templateProcessor->setValue('ur_region', $row['rname']);
     //$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
     $templateProcessor->saveAs($file);
     $qf = explode("|", $row['qfiles']);
     if (!isset($qf[0])) {
         $qf[0] = $qf;
     }
     $mail = \Yii::$app->mail->compose('ur_questions', ['uname' => $row['uname'], 'username' => $user['username'], 'mail' => $user['mail']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo(\Yii::$app->params['uristEmail'])->setSubject('Юридический вопрос')->attach($file);
     foreach ($qf as $q) {
         if ($q != "") {
             $mail->attach($q);
         }
     }
     $mail->send();
     // if($templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx')) {
     //      return true;
     //  }else{
     //    return false;
     // }
 }
开发者ID:pumi11,项目名称:aau,代码行数:39,代码来源:Word.php


示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
开发者ID:Matth--,项目名称:privileges,代码行数:17,代码来源:PrivilegesPermissionMiddleware.php


示例5: onls

 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:28,代码来源:log.php


示例6: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $view = $this->entity;
     $form['#prefix'] = '<div id="views-preview-wrapper" class="views-admin clearfix">';
     $form['#suffix'] = '</div>';
     $form['#id'] = 'views-ui-preview-form';
     $form_state->disableCache();
     $form['controls']['#attributes'] = array('class' => array('clearfix'));
     $form['controls']['title'] = array('#prefix' => '<h2 class="view-preview-form__title">', '#markup' => $this->t('Preview'), '#suffix' => '</h2>');
     // Add a checkbox controlling whether or not this display auto-previews.
     $form['controls']['live_preview'] = array('#type' => 'checkbox', '#id' => 'edit-displays-live-preview', '#title' => $this->t('Auto preview'), '#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'));
     // Add the arguments textfield
     $form['controls']['view_args'] = array('#type' => 'textfield', '#title' => $this->t('Preview with contextual filters:'), '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), '#id' => 'preview-args');
     $args = array();
     if (!$form_state->isValueEmpty('view_args')) {
         $args = explode('/', $form_state->getValue('view_args'));
     }
     $user_input = $form_state->getUserInput();
     if ($form_state->get('show_preview') || !empty($user_input['js'])) {
         $form['preview'] = array('#weight' => 110, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), 'preview' => $view->renderPreview($this->displayID, $args));
     }
     $uri = $view->urlInfo('preview-form');
     $uri->setRouteParameter('display_id', $this->displayID);
     $form['#action'] = $uri->toString();
     return $form;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:29,代码来源:ViewPreviewForm.php


示例7: partialName

 public function partialName($user_id)
 {
     $name = $this->findByAttributes(['user_id' => $user_id])->row_array();
     $lastname = explode(' ', $name['family_name']);
     $partialName = $name['given_name'] . ' ' . $lastname[count($lastname) - 1];
     return $partialName;
 }
开发者ID:kaabsimas,项目名称:caravana,代码行数:7,代码来源:Userinfo.php


示例8: fetchLinks

 /**
  * Fetch Links
  *
  * Fetches a set of links corresponding to an OpenURL
  *
  * @param string $openURL openURL (url-encoded)
  *
  * @return string         raw XML returned by resolver
  * @access public
  */
 public function fetchLinks($openURL)
 {
     // Unfortunately the EZB-API only allows OpenURL V0.1 and
     // breaks when sending a non expected parameter (like an ISBN).
     // So we do have to 'downgrade' the OpenURL-String from V1.0 to V0.1
     // and exclude all parameters that are not compliant with the EZB.
     // Parse OpenURL into associative array:
     $tmp = explode('&', $openURL);
     $parsed = array();
     foreach ($tmp as $current) {
         $tmp2 = explode('=', $current, 2);
         $parsed[$tmp2[0]] = $tmp2[1];
     }
     // Downgrade 1.0 to 0.1
     if ($parsed['ctx_ver'] == 'Z39.88-2004') {
         $openURL = $this->_downgradeOpenUrl($parsed);
     }
     // make the request IP-based to allow automatic
     // indication on institution level
     $openURL .= '&pid=client_ip%3D' . $_SERVER['REMOTE_ADDR'];
     // Make the call to the EZB and load results
     $url = $this->_baseUrl . '?' . $openURL;
     $feed = file_get_contents($url);
     return $feed;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:35,代码来源:EZB.php


示例9: addnew

 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
开发者ID:PHP-web-artisans,项目名称:ustora_backend,代码行数:34,代码来源:brands.php


示例10: beforeMethod

 /**
  * 'beforeMethod' event handles. This event handles intercepts GET requests ending
  * with ?export
  *
  * @param string $method
  * @param string $uri
  * @return bool
  */
 public function beforeMethod($method, $uri)
 {
     if ($method != 'GET') {
         return;
     }
     if ($this->server->httpRequest->getQueryString() != 'export') {
         return;
     }
     // splitting uri
     list($uri) = explode('?', $uri, 2);
     $node = $this->server->tree->getNodeForPath($uri);
     if (!$node instanceof IAddressBook) {
         return;
     }
     // Checking ACL, if available.
     if ($aclPlugin = $this->server->getPlugin('acl')) {
         $aclPlugin->checkPrivileges($uri, '{DAV:}read');
     }
     $this->server->httpResponse->setHeader('Content-Type', 'text/directory');
     $this->server->httpResponse->sendStatus(200);
     $nodes = $this->server->getPropertiesForPath($uri, array('{' . Plugin::NS_CARDDAV . '}address-data'), 1);
     $this->server->httpResponse->sendBody($this->generateVCF($nodes));
     // Returning false to break the event chain
     return false;
 }
开发者ID:GTAWWEKID,项目名称:tsiserver.us,代码行数:33,代码来源:VCFExportPlugin.php


示例11: registerScript

 /**
  * @param $name
  * @param array $params
  * @return string
  */
 public function registerScript($name, $params)
 {
     $out = '';
     if (!isset($this->modx->loadedjscripts[$name])) {
         $src = $params['src'];
         $remote = strpos($src, "http") !== false;
         if (!$remote) {
             $src = $this->modx->config['site_url'] . $src;
             if (!$this->fs->checkFile($params['src'])) {
                 $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper');
                 return false;
             }
         }
         $type = isset($params['type']) ? $params['type'] : end(explode('.', $src));
         if ($type == 'js') {
             $out = '<script type="text/javascript" src="' . $src . '"></script>';
         } else {
             $out = '<link rel="stylesheet" type="text/css" href="' . $src . '">';
         }
         $this->modx->loadedjscripts[$name] = $params;
     } else {
         $out = false;
     }
     return $out;
 }
开发者ID:AgelxNash,项目名称:modx.evo.custom,代码行数:30,代码来源:Assets.php


示例12: openseadragon

 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
开发者ID:UVicLibrary,项目名称:omeka-OpenSeadragon2,代码行数:35,代码来源:Openseadragon.php


示例13: get_exif

 function get_exif($file)
 {
     if (!function_exists('exif_read_data')) {
         return false;
     }
     $exif = @exif_read_data($file, "IFD0");
     if ($exif === false) {
         return false;
     }
     $exif_info = exif_read_data($file, NULL, true);
     $exif_arr = $this->supported_exif();
     $new_exif = array();
     foreach ($exif_arr as $k => $v) {
         $arr = explode('.', $v);
         if (isset($exif_info[$arr[0]])) {
             if (isset($exif_info[$arr[0]][$arr[1]])) {
                 $new_exif[$k] = $exif_info[$arr[0]][$arr[1]];
             } else {
                 $new_exif[$k] = false;
             }
         } else {
             $new_exif[$k] = false;
         }
         if ($k == 'Software' && !empty($new_exif['Software'])) {
             $new_exif['Software'] = preg_replace('/([^a-zA-Z0-9_\\-,\\.\\:&#@!\\(\\)\\s]+)/i', '', $new_exif['Software']);
         }
     }
     return $new_exif;
 }
开发者ID:vluo,项目名称:myPoto,代码行数:29,代码来源:exif.class.php


示例14: setUp

 public function setUp(PDO $pdo, $sql)
 {
     $sql = explode(';', trim($sql));
     foreach ($sql as $query) {
         $pdo->exec(trim($query));
     }
 }
开发者ID:krajewskis,项目名称:ppdo,代码行数:7,代码来源:AbstractQueryTest.php


示例15: generate_cookie

 public function generate_cookie()
 {
     $characters = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0';
     $characters_array = explode(',', $characters);
     shuffle($characters_array);
     return implode('', $characters_array);
 }
开发者ID:jhernani,项目名称:chu,代码行数:7,代码来源:E_security.php


示例16: index

 public function index()
 {
     $this->load->model('design/layout');
     $this->load->model('catalog/category');
     $this->load->model('catalog/product');
     $this->load->model('catalog/information');
     if (isset($this->request->get['route'])) {
         $route = (string) $this->request->get['route'];
     } else {
         $route = 'common/home';
     }
     $layout_id = 0;
     if ($route == 'product/category' && isset($this->request->get['path'])) {
         $path = explode('_', (string) $this->request->get['path']);
         $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
     }
     if ($route == 'product/product' && isset($this->request->get['product_id'])) {
         $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
     }
     if ($route == 'information/information' && isset($this->request->get['information_id'])) {
         $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
     }
     if (!$layout_id) {
         $layout_id = $this->model_design_layout->getLayout($route);
     }
     if (!$layout_id) {
         $layout_id = $this->config->get('config_layout_id');
     }
     $module_data = array();
     $this->load->model('setting/extension');
     $extensions = $this->model_setting_extension->getExtensions('module');
     foreach ($extensions as $extension) {
         $modules = $this->config->get($extension['code'] . '_module');
         if ($modules) {
             foreach ($modules as $module) {
                 if ($module['layout_id'] == $layout_id && $module['position'] == 'header_top' && $module['status']) {
                     $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($module_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $module_data);
     $this->data['modules'] = array();
     foreach ($module_data as $module) {
         $module = $this->getChild('module/' . $module['code'], $module['setting']);
         if ($module) {
             $this->data['modules'][] = $module;
         }
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/header_top.tpl';
     } else {
         $this->template = 'default/template/common/header_top.tpl';
     }
     $this->render();
 }
开发者ID:Vitronic,项目名称:kaufreund.de,代码行数:60,代码来源:header_top.php


示例17: createCommand

 public function createCommand(TaskInfo $taskInfo)
 {
     $task = new Command($taskInfo->getName());
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullName = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullName, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:32,代码来源:Application.php


示例18: imprimirUsuarios

function imprimirUsuarios()
{
    $userQuery = ParseUser::query();
    $userQuery->notEqualTo("username", "tUKgzMsZ09LbLIIdwSZyIH1PVcu24aEcMpxcWH4A");
    $results = $userQuery->find();
    #Cuantos resultados recibio de la base de datos de parse
    //echo "Successfully retrieved " . count($results) . " scores.<br>";
    // Do something with the returned ParseObject values
    for ($i = 0; $i < count($results); $i++) {
        $object = $results[$i];
        //echo $object->getObjectId() . ' - ' . $object->get('username');
        $_strUsuario = $object->get('username');
        $_strUsuarioTO = $object->getObjectId();
        $arraynombre = explode('&', $_strUsuario);
        echo "<tr>";
        echo "<td>" . $arraynombre[1] . "</td>";
        echo "<form action='' method='POST' >";
        echo "<td align='right'> <input type='text' value='Mensaje' name='send'>" . "</td>";
        echo "<td> <input type='submit' value='Enviar Mensaje' name='enviar_Push'>" . "</td>";
        echo "</tr>";
        echo "<input type='hidden' value={$_strUsuario} name='nombreUsuario'>";
        echo "</form> ";
        /*
         echo '<'.'input type='.'"submit"'. 'value="'. $object->get('username').'"';
         echo "<input type='hidden' value=$costo  name='costo'>";
         echo "<br>";
        */
    }
}
开发者ID:ericzubin,项目名称:PUSHWEB,代码行数:29,代码来源:enviarPushnumero.php


示例19: getLocks

 /**
  * Returns a list of Sabre\DAV\Locks\LockInfo objects
  *
  * This method should return all the locks for a particular uri, including
  * locks that might be set on a parent uri.
  *
  * If returnChildLocks is set to true, this method should also look for
  * any locks in the subtree of the uri for locks.
  *
  * @param string $uri
  * @param bool $returnChildLocks
  * @return array
  */
 function getLocks($uri, $returnChildLocks)
 {
     $lockList = [];
     $currentPath = '';
     foreach (explode('/', $uri) as $uriPart) {
         // weird algorithm that can probably be improved, but we're traversing the path top down
         if ($currentPath) {
             $currentPath .= '/';
         }
         $currentPath .= $uriPart;
         $uriLocks = $this->getData($currentPath);
         foreach ($uriLocks as $uriLock) {
             // Unless we're on the leaf of the uri-tree we should ignore locks with depth 0
             if ($uri == $currentPath || $uriLock->depth != 0) {
                 $uriLock->uri = $currentPath;
                 $lockList[] = $uriLock;
             }
         }
     }
     // Checking if we can remove any of these locks
     foreach ($lockList as $k => $lock) {
         if (time() > $lock->timeout + $lock->created) {
             unset($lockList[$k]);
         }
     }
     return $lockList;
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:40,代码来源:FS.php


示例20: testInvalidDates

 /**
  * Tests invalid data.
  */
 public function testInvalidDates()
 {
     $composer = new Composer();
     // Invalid date/time parts
     $units = array('second' => array(-1, 61, '-1', '61'), 'minute' => array(-1, 61, '-1', '61'), 'hour' => array(-1, 24, '-1', '24'), 'day' => array(0, 32, '0', '32'), 'month' => array(0, 13, '0', '13'), 'year' => array(1901, 2038, '1901', '2038'));
     foreach ($units as $unit => $tests) {
         foreach ($tests as $test) {
             try {
                 $composer->{'set' . ucfirst($unit)}($test);
             } catch (\Exception $e) {
                 $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
                 $this->assertSame(constant('\\Jyxo\\Time\\ComposerException::' . strtoupper($unit)), $e->getCode(), sprintf('Failed test for unit %s and value %s.', $unit, $test));
             }
         }
     }
     // Incomplete date
     try {
         $date = $composer->getTime();
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
         $this->assertSame(ComposerException::NOT_COMPLETE, $e->getCode());
     }
     // Invalid dates
     $tests = array('2002-04-31', '2003-02-29', '2004-02-30', '2005-06-31', '2006-09-31', '2007-11-31');
     foreach ($tests as $test) {
         try {
             list($year, $month, $day) = explode('-', $test);
             $composer->setDay($day)->setMonth($month)->setYear($year);
             $time = $composer->getTime();
         } catch (\Exception $e) {
             $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
             $this->assertSame(ComposerException::INVALID, $e->getCode(), sprintf('Failed test for %s.', $test));
         }
     }
 }
开发者ID:JerryCR,项目名称:php-2,代码行数:38,代码来源:ComposerTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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