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 bulletin board for virtual communities. (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. For beginners, read the code carefully and 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 in head by others. inc downloads your source code. It is best to use php as the suffix so that your server will first intercept it for processing */
Echo "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.