PHP personal website set up a serial talk (ii)

Source: Internet
Author: User
Tags html header processing text strlen
Three first page press release, make your update easier (ON)
--------each time in the home page to add a message, add two words, you have to upload the entire page, it is not worth! So like the blue wind such a lazy man thought of a once and for all, real dynamic real-time, remote management editing, automatic maintenance functions. It can also be used to make bulletin boards for virtual communities. (If change, change it, you can put your news center of the news on the homepage automatically generated feed, hehe. So many functions, we forgive, hehe.
--------to insert a few topics aside, when we do the site, is the HTML in the middle of the embellishment of PHP, or PHP to generate HTML? A professional site can focus on a single page, using this page to invoke different modules to achieve each of the child functions (so that the client is not only one page?) I haven't tried it.) In any case, functional modular software reuse is an important method of efficient development (also can save your host space Oh ^_^).
--------Well, let's just come up and get the function modular. Beginners Please read the code carefully, especially the use of basic functions. Master can skip this paragraph, hehe (so seriously?) I was embarrassed to see 9-().
<?php
/*head.php in order to avoid being other people directly type Head.inc download your source code, it is best to use PHP suffix, so that your server will first intercept it for processing, hehe
echo "echo "The path of the network management"//if the title is constant, you can do a function.
echo "</title>?>
This is a functional block that writes an HTML header.
<?php
/*makestr.php defines a function of a hyperlink in a public processing text, assuming that the link form in the text is the path of the ${http://www.yoyonow.net| network management}*/
function Makestr ($text)
{$str = $text;
$a =strstr ($s, ' $} ');//Remove substring before ' ${' in $s
if ($a) {
$b =strstr ($a, '} ');
if ($b) {
$la =strlen ($a); $ls =strlen ($s);//String length
$s =substr ($a, 0, $ls-$la);//Fetch substring, second argument to start, third argument to number of characters
$a =substr ($a, 2);//Remove ' ${'
$LB =strlen ($b); $la =strlen ($a);
$a =substr ($a, 0, $la-$lb);//Remove Hyperlink section
$b =substr ($b, 1);//Remove '} '
$ta =strstr ($a, "|"); /Find out if there is any text that needs to be linked
if ($ta) {
$la =strlen ($a); $lt = (strlen ($TA);
$linktext =substr ($a, $la-$lt + 1);
$a =substr ($a, 0, $la-$lt);
}
else{
$linktext = $a;
}
$s = $s. " <a herf= "". $a. "" $linktext. " </a> $b;//Prepare to return a string
}
}
return ($s);
}

--------If you're a novice, you should look for an introductory HTML book. Otherwise it is hard to become a PHP master. These functions, which you begin to look very simple in handling strings, are capable of doing a lot of beautiful things with your ingenious application. Next, we can see that we prepared the results of most of the day, hehe.


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.