Php practice day 10

Source: Internet
Author: User

Today, we have finished the front-end of the waterfall message board. Let's take a look.

 

 

 

 

 

 

 


What I learned today

Serialize () serialization

Unserialize () deserialization

The two functions compile the config_set () and config_get () functions.


[Php]
/**
* Used to write out array configurations
*/
Function config_set ($ fileName, $ arr_var ){
File_put_contents ($ fileName, serialize ($ arr_var ));
}
/**
* Used to read the configuration. The returned value is the set array.
*/
Function config_get ($ fileName ){
If (file_exists ($ fileName )){
Return unserialize (file_get_contents ($ fileName ));
}
}

/**
* Used to write out array configurations
*/
Function config_set ($ fileName, $ arr_var ){
File_put_contents ($ fileName, serialize ($ arr_var ));
}
/**
* Used to read the configuration. The returned value is the set array.
*/
Function config_get ($ fileName ){
If (file_exists ($ fileName )){
Return unserialize (file_get_contents ($ fileName ));
}
} Call Method


[Php]
$ Config = array (
'Title' => 'waterfall message board ',
"B" => 'aaa'
);
 
Config_set ("data. php", $ config );
 
 
$ Config = config_get ('data. php ');
 
Var_dump ($ config );

$ Config = array (
'Title' => 'waterfall message board ',
"B" => 'aaa'
);

Config_set ("data. php", $ config );
 

$ Config = config_get ('data. php ');

Var_dump ($ config );
2. How to Use the '[]' in the jquery selector, remove the style from the removedClass, and add the style to the addClass to easily highlight the style.

Var focus_li = $ ("# menu li [class! = Nav-header] ");
Focus_li.click (function (){

Focus_li.removeClass ("active"); // remove all highlighted styles
$ (This). addClass ("active"); // Add a highlighted style to the clicked

 

3. For session, unset ($ _ sesstion) cannot be cleared. session_unset () is used ()

 


4. Rewrite the chrome browser in the message form at the front end. The effect of IE is less special and not very nice.


[Html]
<Form class = "form-horizontal" action = "index. php? M = index & a = add "method =" post ">
<Div class = "control-group">
<Label class = "control-label" for = "content"> message content </label>
<Div class = "controls">
<Textarea class = "span8" rows = "3" id = "content" name = "content" placeholder = "Enter your message content"> </textarea>
</Div>
</Div>
 
<Div class = "control-group">
<Label class = "control-label" for = "userName"> nickname </label>
<Div class = "controls">
<Input class = "span2" type = "text" id = "userName" name = "userName" placeholder = "enter your name">

Contact info

<Input class = "span2" type = "text" id = "email" name = "email" placeholder = "QQ, Email, and mobile phone">

<Input class = "btn-info" type = "button" id = "submit" name = "submit" value = "">
 
</Div>
</Div>
 
</Form>

<Form class = "form-horizontal" action = "index. php? M = index & a = add "method =" post ">
<Div class = "control-group">
<Label class = "control-label" for = "content"> message content </label>
<Div class = "controls">
<Textarea class = "span8" rows = "3" id = "content" name = "content" placeholder = "Enter your message content"> </textarea>
</Div>
</Div>

<Div class = "control-group">
<Label class = "control-label" for = "userName"> nickname </label>
<Div class = "controls">
<Input class = "span2" type = "text" id = "userName" name = "userName" placeholder = "enter your name">

Contact info

<Input class = "span2" type = "text" id = "email" name = "email" placeholder = "QQ, Email, and mobile phone">

<Input class = "btn-info" type = "button" id = "submit" name = "submit" value = "">

</Div>
</Div>

</Form>


5. The drop-down button in the background is very beautiful.


[Html]
<Div class = "span4" style = "text-align: right">
<Div class = "btn-group" style = "text-align: left">
<Button class = "btn-danger dropdown-toggle" data-toggle = "dropdown">
Welcome back <{$ userName}> <span class = "caret"> </span>
</Button>
<Ul class = "dropdown-menu">
<Li> <a href = "index. php"> View websites </a> </li>
<Li class = "divider"> </li>
<Li> <a href = "admin. php? M = admin & a = ulogin "> log out </a> </li>
</Ul>
</Div>
</Div>

<Div class = "span4" style = "text-align: right">
<Div class = "btn-group" style = "text-align: left">
<Button class = "btn-danger dropdown-toggle" data-toggle = "dropdown">
Welcome back <{$ userName}> <span class = "caret"> </span>
</Button>
<Ul class = "dropdown-menu">
<Li> <a href = "index. php"> View websites </a> </li>
<Li class = "divider"> </li>
<Li> <a href = "admin. php? M = admin & a = ulogin "> log out </a> </li>
</Ul>
</Div>
</Div>

 

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.