PHP personal websites establish a series of lectures (2) _ php Basics

Source: Internet
Author: User
Tags php basics
PHP personal websites establish a series of lectures (2) 3 homepage news releases, making 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 -().
/* 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" "<Br> echo" "// if the title changes frequently, you can create a function. <Br> echo""
?>
This is a functional block for writing html headers.
/* 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. ". $ linktext.". $ 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.