PHP and MySQL Web development from novice to expert, 9th day-Summary

Source: Internet
Author: User
Tags change settings php session php and mysql unique id

1. $_request,$_post,$_get in PHP and contact _2015_1025

2. mysql_php study notes _2015_0907_php use small summary

2.1. Enable the PDO object to throw a pdoexception at any moment when the task is not successfully executed

After a successful connection is established, the PDO switches to the "fail-silent" mode. When something goes wrong, it makes it hard to find the error and handle it in a capacity.

We want to make the PDO object throw a pdoexception at any moment when the task is not successfully executed, and you can configure it by calling the SetAttribute method of the PDO object so that it does the function mentioned above.

2.2. Problem with character encoding

Set the PDO object to UTF-8 encoding.

$pdo->setattribute (Pdo::attr_errmode, pdo::errmode_exception);

$pdo->exec (' SET NAMES ' utf8 ');

3. mysql_php Learning note _2015_0907_php connecting the database with PDO error could not find driver

4. Mysql_php study notes _2015_0906_ using PHP templates

In this note, these patterns are used to write. That is, template + controller.

5. Summary of garbled problems in Zend Studio

6. mysql_php Learning notes _2015.04.19_php Connection Database

7. Session usage.

The PHP session variable is used to store information about a user's session, or to change settings for a user session. The session variable holds information that is single-user and available to all pages in the application.

Session information is temporary and may be deleted after the user leaves the site. Permanent storage of information is required to store the information in the database.

The session works by creating a unique ID (UID) for each visitor and storing the variables based on the UID. The uid is stored in a cookie or transmitted through a URL.

Usage:

7.1 Start Session,Session_Start (), this function should precede the

  <?php session_start ();?>

7.2 Store session variables. Set the variable name directly and assign the value.

  Store session Data  $_session[' views ']=1;

7.3 End Session, if you want to delete some session data, you can use the unset or session_destory () function.

  The unset () function is used to release the specified session variable:
Session_Start (); unset ($_session[' Loggedin ']); unset ($_session[' email ']); unset ($_session[' Password ']);
  You can also end the session with the Session_destory () function:
<? PHP   Session_Start (); Session_destroy ();  ? >
Note: session_destory () resets the session and you will lose all stored session data.

PHP and MySQL Web development from novice to expert, 9th day-Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.