$ (Function () {, function

Source: Internet
Author: User

$ (Function () {, function

"$ (Function () {" similar code appears in the project.

$ (Document). ready (function () {// program segment}) is equivalent to $ (function () {// program segment })


$ (Function (){}

This is the JQuery syntax. $ indicates the JQuery object. It can be used in several ways. For example, if the selector string and page object are passed in directly, this function is executed when the page is loaded.

Function () function usage

A function is actually a unified code block that you can call at any time.

Creating PHP functions:
How to Create a PHP function:

All functions start with the word "function ()"
All functions must start with "function ()"
Name the function-It shoshould be possible to understand what the function does by its name. The name can start with a letter or underscore (not a number)
Name a function: the best way to name a function is to have the same name as the function. The name can contain letters or underscores ).
Add a "{"-The function code starts after the opening curly brace
Add a "{": the code of the function must be written after the "{" symbol.
Insert the function code
Insert a function code
Add a "}"-The function is finished by a closing curly brace
Add "}": After the function is written, the "}" symbol must be added.
Example
Case
A simple function that writes my name when it is called:
The following is a simple PHP function case. When we call it, it can output our name:

<Html> <body>
<? Phpfunction writeMyName () {echo "Kai Jim Refsnes ";}
WriteMyName ();?>
</Body>

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.