當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。