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


PHP serialize函数代码示例

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


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

示例1: indexAction

 /**
  * Reference purchase summary
  *
  * @Route()
  * @Method({"GET", "POST"})
  * @Template()
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $previouslyPostedData = null;
     // if we are not posting new data, and a request for $this->formType is stored in the session, prepopulate the form with the stored request
     $storedRequest = unserialize($request->getSession()->get($this->formType->getName()));
     if ($request->isMethod('GET') && $storedRequest instanceof Request) {
         $previouslyPostedData = $this->createForm($this->formType)->handleRequest($storedRequest)->getData();
     }
     $form = $this->createForm($this->formType, $previouslyPostedData);
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             // Persist the case to IRIS
             /** @var ReferencingCase $case */
             $case = $form->getData()['case'];
             $this->irisEntityManager->persist($case);
             /** @var ReferencingApplication $application */
             foreach ($case->getApplications() as $application) {
                 // Always default
                 $application->setSignaturePreference(SignaturePreference::SCAN_DECLARATION);
                 $this->irisEntityManager->persist($application, array('caseId' => $case->getCaseId()));
                 // Persist each guarantor of the application
                 if (null !== $application->getGuarantors()) {
                     foreach ($application->getGuarantors() as $guarantor) {
                         $this->irisEntityManager->persist($guarantor, array('applicationId' => $application->getApplicationId()));
                     }
                 }
             }
             $request->getSession()->set('submitted-case', serialize($case));
             // Send the user to the success page
             return $this->redirect($this->generateUrl('barbon_hostedapi_agent_reference_newreference_tenancyagreement_index'), 301);
         }
     }
     return array('form' => $form->createView());
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:45,代码来源:NewController.php

示例2: indexAction

 /**
  * @Route("/{applicationId}")
  * @Method({"GET", "POST"})
  * @Template()
  * @param Request $request
  * @param $applicationId
  * @return array
  */
 public function indexAction(Request $request, $applicationId)
 {
     // Validate the $applicationId, throws Exception if invalid.
     $application = $this->getApplication($this->irisEntityManager, $applicationId);
     // Get the Case for this Tenant and put in the session, as it's needed throughout
     $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
     $request->getSession()->set('submitted-case', serialize($case));
     // Create an empty ReferencingGuarantor object.
     $guarantor = new ReferencingGuarantor();
     $guarantor->setCaseId($application->getCaseId());
     // Build the form.
     $form = $this->createForm($this->formType, $guarantor, array('guarantor_decorator' => $this->referencingGuarantorDecoratorBridgeSubscriber->getGuarantorDecorator(), 'attr' => array('id' => 'generic_step_form', 'class' => 'referencing branded individual-guarantor-form', 'novalidate' => 'novalidate')));
     // Process a client round trip, if necessary
     if ($request->isXmlHttpRequest()) {
         $form->submit($request);
         return $this->render('BarbonHostedApiLandlordReferenceBundle:NewReference/Guarantor/Validate:index.html.twig', array('form' => $form->createView()));
     }
     // Submit the form.
     $form->handleRequest($request);
     if ($form->isValid()) {
         $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
         // Dispatch the new guarantor reference event.
         $this->eventDispatcher->dispatch(NewReferenceEvents::GUARANTOR_REFERENCE_CREATED, new NewGuarantorReferenceEvent($case, $application, $guarantor));
         // Send the user to the success page.
         return $this->redirectToRoute('barbon_hostedapi_landlord_reference_newreference_guarantor_confirmation_index', array('applicationId' => $applicationId));
     }
     return array('form' => $form->createView());
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:36,代码来源:NewController.php

示例3: sessionEncode

 /**
  * 编码session
  * @param mixed $session_data
  * @return string
  */
 public static function sessionEncode($session_data = '')
 {
     if ($session_data !== '') {
         return serialize($session_data);
     }
     return '';
 }
开发者ID:Lazy-hong,项目名称:QinIM-Server,代码行数:12,代码来源:Context.php

示例4: addNew

 /**
  * Adds new User Story
  * 
  * @param   integer     $user       User ID
  * @param   array       $story      User Story 
  * @return  array | bool     
  */
 public function addNew($user, $story)
 {
     $new = new Model_Userstory();
     $new->fromArray(array('user' => $user, 'content' => $story['content'], 'date' => date('Y-m-d H:i:s')));
     if (isset($story['gallery']) && is_array($story['gallery'])) {
         $storyMedia = new Model_Userstorymedia();
         $storyMedia->photos = serialize($story['gallery']);
         $storyMedia->totalphotos = count($story['gallery']);
     }
     if (isset($story['videos']) && is_array($story['videos'])) {
         if (!isset($storyMedia)) {
             $storyMedia = new Model_Userstorymedia();
         }
         $storyMedia->videos = serialize($story['videos']);
         $storyMedia->totalvideos = count($story['videos']);
     }
     if (isset($storyMedia)) {
         $new->Media = $storyMedia;
     }
     try {
         $new->save();
     } catch (Doctrine_Exception $e) {
         return $e->getMessage();
     }
     return $new->toArray();
 }
开发者ID:royaltyclubvp,项目名称:BuzzyGals,代码行数:33,代码来源:Userstory.php

示例5: ewww_ngg_new_thumbs

        function ewww_ngg_new_thumbs($gid, $images)
        {
            // store the gallery id, seems to help avoid errors
            $gallery = $gid;
            // prepare the $images array for POSTing
            $images = serialize($images);
            ?>
                <div id="bulk-forms"><p><?php 
            _e('The thumbnails for your new images have not been optimized.', EWWW_IMAGE_OPTIMIZER_DOMAIN);
            ?>
</p>
                <form id="thumb-optimize" method="post" action="admin.php?page=ewww-ngg-thumb-bulk">
			<?php 
            wp_nonce_field('ewww-image-optimizer-bulk', 'ewww_wpnonce');
            ?>
			<input type="hidden" name="ewww_attachments" value="<?php 
            echo $images;
            ?>
">
                        <input type="submit" class="button-secondary action" value="<?php 
            _e('Optimize Thumbs', EWWW_IMAGE_OPTIMIZER_DOMAIN);
            ?>
" />
                </form> 
<?php 
        }
开发者ID:leotaillard,项目名称:btws2016,代码行数:26,代码来源:nextgen-integration.php

示例6: shouldDeserialize

 /**
  * @test
  */
 public function shouldDeserialize()
 {
     $helper = new SamlSpInfoHelper();
     $expectedSamlSpInfo = $helper->getSamlSpInfo();
     $unserializedSamlSpInfo = unserialize(serialize($expectedSamlSpInfo));
     $this->assertEquals($expectedSamlSpInfo, $unserializedSamlSpInfo);
 }
开发者ID:iambrosi,项目名称:SamlSPBundle,代码行数:10,代码来源:SamlSpInfoTest.php

示例7: mark_review

 static function mark_review()
 {
     global $wpdb;
     $_watu = new WatuPRO();
     // this will only happen for logged in users
     if (!is_user_logged_in()) {
         return false;
     }
     $taking_id = $_watu->add_taking($_POST['exam_id'], 1);
     // select current data if any
     $marked_for_review = $wpdb->get_var($wpdb->prepare("SELECT marked_for_review FROM " . WATUPRO_TAKEN_EXAMS . "\n\t\t\tWHERE ID=%d", $taking_id));
     if (empty($marked_for_review)) {
         $marked_for_review = array("question_ids" => array(), "question_nums" => array());
     } else {
         $marked_for_review = unserialize($marked_for_review);
     }
     if ($_POST['act'] == 'mark') {
         $marked_for_review['question_ids'][] = $_POST['question_id'];
         $marked_for_review['question_nums'][] = $_POST['question_num'];
     } else {
         // unmark
         foreach ($marked_for_review['question_ids'] as $cnt => $id) {
             if ($id == $_POST['question_id']) {
                 unset($marked_for_review['question_ids'][$cnt]);
             }
         }
         foreach ($marked_for_review['question_nums'] as $cnt => $num) {
             if ($num == $_POST['question_num']) {
                 unset($marked_for_review['question_nums'][$cnt]);
             }
         }
     }
     // now save
     $wpdb->query($wpdb->prepare("UPDATE " . WATUPRO_TAKEN_EXAMS . " SET marked_for_review=%s WHERE ID=%d", serialize($marked_for_review), $taking_id));
 }
开发者ID:alvarpoon,项目名称:anbig,代码行数:35,代码来源:questions.php

示例8: setStatuses

 public function setStatuses($v)
 {
     if (!is_array($v)) {
         $v = array();
     }
     parent::setStatuses(serialize($v));
 }
开发者ID:DBezemer,项目名称:server,代码行数:7,代码来源:Scheduler.php

示例9: ApplyChanges

 public function ApplyChanges()
 {
     parent::ApplyChanges();
     $this->RegisterAction('Volume', 'Lautstärke', $typ = 1, $profil = '');
     $this->RegisterAction('Mute', 'Stumm', $typ = 0, $profil = 'RPC.OnOff');
     $this->RegisterVariableInteger('GroupMember', 'Gruppe', 0);
     if ($this->CheckConfig() === true) {
         $zoneConfig = IPS_GetKernelDir() . '/modules/ips2rpc/sonos_zone.config';
         if (!file_exists($zoneConfig)) {
             $file = $this->API()->BaseUrl(true) . '/status/topology';
             if ($xml = simplexml_load_file($file)) {
                 $out = [];
                 foreach ($xml->ZonePlayers->ZonePlayer as $item) {
                     if ($v = (array) $item->attributes()) {
                         $v = array_shift($v);
                     }
                     $v['name'] = (string) $item;
                     $out[$v['name']] = $v;
                 }
                 file_put_contents($zoneConfig, serialize($out));
             }
         }
         $this->Update();
     }
 }
开发者ID:TierFreund,项目名称:Ips2rpc,代码行数:25,代码来源:module.php

示例10: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Order();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Order'])) {
         $model->attributes = $_POST['Order'];
         $model->id = F::get_order_id();
         $model->user_id = Yii::app()->user->id ? Yii::app()->user->id : '0';
         if ($model->save()) {
             $cart = Yii::app()->cart;
             $mycart = $cart->contents();
             foreach ($mycart as $mc) {
                 $OrderItem = new OrderItem();
                 $OrderItem->order_id = $model->order_id;
                 $OrderItem->item_id = $mc['id'];
                 $OrderItem->title = $mc['title'];
                 $OrderItem->pic_url = serialize($mc['pic_url']);
                 $OrderItem->sn = $mc['sn'];
                 $OrderItem->num = $mc['qty'];
                 $OrderItem->save();
             }
             $cart->destroy();
             $this->redirect(array('success'));
         }
     }
     //        $this->render('create', array(
     //            'model' => $model,
     //        ));
 }
开发者ID:rainsongsky,项目名称:yincart,代码行数:34,代码来源:OrderController.php

示例11: add

 /**
  * 添加购物车
  * @access  public
  * @param array $data
  * <code>
  * $data为数组包含以下几个值
  * $Data=array(
  *  "id"=>1,                        //商品ID
  *  "name"=>"后盾网2周年西服",         //商品名称
  *  "num"=>2,                       //商品数量
  *  "price"=>188.88,                //商品价格
  *  "options"=>array(               //其他参数,如价格、颜色可以是数组或字符串|可以不添加
  *      "color"=>"red",
  *      "size"=>"L"
  *  )
  * </code>
  * @return void
  */
 static function add($data)
 {
     if (!is_array($data) || !isset($data['id']) || !isset($data['name']) || !isset($data['num']) || !isset($data['price'])) {
         throw_exception('购物车ADD方法参数设置错误');
     }
     $data = isset($data[0]) ? $data : array($data);
     $goods = self::getGoods();
     //获得商品数据
     //添加商品增持多商品添加
     foreach ($data as $v) {
         $options = isset($v['options']) ? $v['options'] : '';
         $sid = substr(md5($v['id'] . serialize($options)), 0, 8);
         //生成维一ID用于处理相同商品有不同属性时
         if (isset($goods[$sid])) {
             if ($v['num'] == 0) {
                 //如果数量为0删除商品
                 unset($goods[$sid]);
                 continue;
             }
             //已经存在相同商品时增加商品数量
             $goods[$sid]['num'] = $goods[$sid]['num'] + $v['num'];
             $goods[$sid]['total'] = $goods[$sid]['num'] * $goods[$sid]['price'];
         } else {
             if ($v['num'] == 0) {
                 continue;
             }
             $goods[$sid] = $v;
             $goods[$sid]['total'] = $v['num'] * $v['price'];
         }
     }
     self::save($goods);
 }
开发者ID:jyht,项目名称:v5,代码行数:50,代码来源:Cart.class.php

示例12: export

 /**
  * Export data
  * @param string $format
  * @param array $options
  * @throws Exception
  */
 public function export($format = self::EXPORT_DISPLAY, $options = array())
 {
     global $wpdb;
     $options = array();
     $options['upload_dir'] = wp_upload_dir();
     $options['options'] = array();
     $options['options']['permalink_structure'] = get_option('permalink_structure');
     $widgets = $wpdb->get_results("SELECT option_name, option_value FROM {$wpdb->options} WHERE option_name LIKE 'widget_%'");
     foreach ($widgets as $widget) {
         $options['options'][$widget->option_name] = $this->compress(get_option($widget->option_name));
     }
     $options['options']['sidebars_widgets'] = $this->compress(get_option('sidebars_widgets'));
     $current_template = get_option('stylesheet');
     $options['options']["theme_mods_{$current_template}"] = $this->compress(get_option("theme_mods_{$current_template}"));
     $data = serialize($options);
     if ($format == self::EXPORT_DISPLAY) {
         echo '<textarea>' . $data . '</textarea>';
     }
     //export settings to file
     if ($format == self::EXPORT_FILE) {
         $path = isset($options['path']) ? $options['path'] : self::getWpOptionsPath();
         if (!file_put_contents($path, $data)) {
             throw new Exception("Cannot save settings to: " . $path);
         }
     }
 }
开发者ID:clevervaughn,项目名称:dottiesbiscuitbarn,代码行数:32,代码来源:ctDemoExporterImporter.class.php

示例13: ajax_return

 /**
  *	控制器 AJAX脚本输出
  *  Controller中使用方法:$this->Controller->ajax_return()
  * 	@param  int     $status  0:错误信息|1:正确信息
  * 	@param  string  $message  显示的信息
  * 	@param  array   $data    传输的信息
  * 	@param  array   $type    返回数据类型,json|xml|eval|jsonp
  *  @return object
  */
 public function ajax_return($status, $message = '', $data = array(), $type = 'json')
 {
     $return_data = array('status' => $status, 'message' => $message, 'data' => $data);
     $type = strtolower($type);
     if ($type == 'json') {
         header("Content-type: application/json");
         exit(json_encode($return_data));
     } elseif ($type == 'xml') {
         header('Content-type: text/xml');
         $xml = '<?xml version="1.0" encoding="utf-8"?>';
         $xml .= '<return>';
         $xml .= '<status>' . $status . '</status>';
         $xml .= '<message>' . $message . '</message>';
         $xml .= '<data>' . serialize($data) . '</data>';
         $xml .= '</return>';
         exit($xml);
     } elseif ($type == "jsonp") {
         $callback = $this->get_gp('callback');
         $json_data = json_encode($return_data);
         if (is_string($callback) && isset($callback[0])) {
             exit("{$callback}({$json_data});");
         } else {
             exit($json_data);
         }
     } elseif ($type == 'eval') {
         exit($return_data);
     } else {
     }
 }
开发者ID:superbogy,项目名称:initphp,代码行数:38,代码来源:controller.init.php

示例14: insertTemplates

 /**
  * Insert the templates.
  */
 private function insertTemplates()
 {
     /*
      * Fallback templates
      */
     // build templates
     $templates['core']['default'] = array('theme' => 'core', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     $templates['core']['home'] = array('theme' => 'core', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[main]', 'names' => array('main'))));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['core']['default']);
     $this->getDB()->insert('themes_templates', $templates['core']['home']);
     /*
      * Triton templates
      */
     // search will be installed by default; already link it to this template
     $extras['search_form'] = $this->insertExtra('search', ModuleExtraType::widget(), 'SearchForm', 'form', null, 'N', 2001);
     // build templates
     $templates['triton']['default'] = array('theme' => 'triton', 'label' => 'Default', 'path' => 'Core/Layout/Templates/Default.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[left,main,main,main]', 'names' => array('main', 'left', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => false)));
     $templates['triton']['home'] = array('theme' => 'triton', 'label' => 'Home', 'path' => 'Core/Layout/Templates/Home.html.twig', 'active' => 'Y', 'data' => serialize(array('format' => '[/,advertisement,advertisement,advertisement],[/,/,top,top],[/,/,/,/],[main,main,main,main],[left,left,right,right]', 'names' => array('main', 'left', 'right', 'top', 'advertisement'), 'default_extras' => array('top' => array($extras['search_form'])), 'image' => true)));
     // insert templates
     $this->getDB()->insert('themes_templates', $templates['triton']['default']);
     $this->getDB()->insert('themes_templates', $templates['triton']['home']);
     /*
      * General theme settings
      */
     // set default theme
     $this->setSetting('Core', 'theme', 'triton', true);
     // set default template
     $this->setSetting('Pages', 'default_template', $this->getTemplateId('default'));
     // disable meta navigation
     $this->setSetting('Pages', 'meta_navigation', false);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:35,代码来源:Installer.php

示例15: testRequireAllUnset

 public function testRequireAllUnset()
 {
     $this->require->setRequire('vendor/name');
     $this->assertFalse($this->require->getAll());
     $this->assertEquals('C:50:"holisticagency\\satis\\utilities\\SatisRequireOptions":53:{a:1:{s:7:"require";a:1:{s:11:"vendor/name";s:1:"*";}}}', serialize($this->require));
     $this->assertFalse($this->require->getAll());
 }
开发者ID:holisticagency,项目名称:satis-file-manager,代码行数:7,代码来源:SatisRequireOptionsTest.php


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