Session on setting up a PHP personal website (2)

Source: Internet
Author: User

Three homepage news publishing makes it easier for you to update (on)
-------- Each time you add a message to the homepage and add two sentences, You have to upload the entire page. This is really not worth it! As a result, lazy people like lanfeng have come up with a permanent solution to implement dynamic real-time, remote management and editing, and automatic maintenance. It can also be used as a virtual Community . (If you change it, you can automatically generate a feed for your news center on the homepage .) Forgive me for all these features.
-------- Insert a few digress first. When we build a website, do we use HTML to embellish PHP in the middle or use PHP to generate HTML? Professional websites can centralize a function on one page and call different modules to implement each sub-function. (does the client have only one page? I have not tried ). In any case, software reuse with modular functions is an important method for efficient development (it can also save your host space ).
-------- Okay. let's modularize the functions. Read carefully for beginners Code Pay special attention to the usage of basic functions. Experts can skip this section, huh, huh (so seriously? I am so sorry -().
<? PHP
/* Head. php to avoid being directly typed into head. Inc to download your Source code , It is best to use PHP as the suffix so that your server will first intercept it for processing */
Echo "<HTML> Echo "the path to network management" // if the title changes frequently, you can create a function.
Echo "</title> ?>
This is a functional block for writing HTML headers.
<? PHP
/* Makestr. php defines a function that processes hyperlinks in the public text, assuming the link form in the text is $ {http://www.yoyonow.net | Network Management path }*/
Function makestr ($ text)
{$ STR = $ text;
$ A = strstr ($ S, '$}'); // remove the substring before '$ {' in $ S.
If ($ ){
$ B = strstr ($ ,'}');
If ($ B ){
$ LA = strlen ($ A); $ ls = strlen ($ S); // obtain the string length
$ S = substr ($ A, 0, $ LS-$ la); // obtain the substring. The second parameter is the starting point, and the third parameter is the number of characters.
$ A = substr ($ A, 2); // remove '$ {'
$ LB = strlen ($ B); $ LA = strlen ($ );
$ A = substr ($ A, 0, $ la-$ lb); // retrieve the hyperlink
$ B = substr ($ B, 1); // remove '}'
$ Ta = strstr ($ A, "|"); // you can specify whether the link text exists.
If ($ Ta ){
$ LA = strlen ($ A); $ lT = (strlen ($ Ta );
$ Linktext = substr ($ A, $ la-$ LT + 1 );
$ A = substr ($ A, 0, $ la-$ lt );
}
Else {
$ Linktext = $;
}
$ S = $ S. "<a herf =" ". $ A." ">. $ linktext." </a>. $ B; // prepare the returned string.
}
}
Return ($ S );
}

-------- If you are a newbie, you should look for an HTML getting started book. Otherwise, it is difficult to become a PHP master. These functions that you start to look very simple and process strings. After your clever use, you can do a lot of beautiful things. In the next lecture, we can see the results we have prepared for a long time.

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.