Home  >  Article  >  Backend Development  >  A series of lectures on setting up a PHP personal website (2)_PHP tutorial

A series of lectures on setting up a PHP personal website (2)_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:04:13744browse

Three homepage news releases to make updates easier for you (Part 1)
--------Every time you add a message or two sentences to the homepage, you have to upload the entire page again, which is really not worth it! So lazy people like Lan Feng thought of a once and for all solution, real dynamic real-time, remote management and editing, and automatic maintenance functions. It can also be used as a bulletin board for virtual communities. (If you change it, you can automatically generate a feed of the news in your news center on the homepage, haha.) With so many functions, everyone will forgive me, hehe.
--------A few digressions first. When we build a website, do we use HTML interspersed with PHP, or do we use PHP to generate HTML? Professional sites can concentrate one function on one page, and call different modules through this page to realize each sub-function (does the client only have one page? I have not tried it). In any case, functional modular software reuse is an important method for efficient development (it can also save your host space^_^).
--------Okay, let’s modularize the functions together. Beginners please read the code carefully, paying special attention to the usage of basic functions. Experts can skip this section, haha ​​(Why are you so serious? It makes people feel embarrassed 9-().
/*head.php In order to avoid others typing head directly. inc to download your source code, it is best to use php as the suffix, so that your server will intercept it first and process it, haha*/
echo "" <br>echo "Road to Network Management"//If the title changes frequently, you can make a function <br>echo ""
?>
This is a way to write html header. A function block of
/*makestr.php defines a function for processing hyperlinks in text. It is assumed that the link form in the text is ${http://www.yoyonow.net|Network Management Road}*/
function makestr($text)
{ $str=$text;
$a=strstr($s,'$}');//Cut out in $s'${ 'The previous substring
if($a){
$b=strstr($a,'}');
if($b){
$la=strlen($a) ;$ls=strlen($s);//Get the string length
$s=substr($a,0,$ls-$la);//Get the substring, the second parameter is the starting point, the third The first parameter is the number of characters
$a=substr($a,2);//remove '${'
$lb=strlen($b);$la=strlen($a);
$a=substr($a,0,$la-$lb);//Remove the hyperlink part
$b=substr($b,1);//Remove the '}'
$ ta=strstr($a,"|");//Find whether there is 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.".$linktext." .$b; // Prepare to return string
}
}
return($s);
}

--------If you are a newbie , then you should look for an introductory book on HTML. Otherwise it is difficult to become a PHP master. These string processing functions, which may seem very simple at first, can do many beautiful things through your clever use. In the next lecture, we can see the results of what we have prepared for most of the day, haha.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316042.htmlTechArticleThree homepage news releases, making it easier for you to update (Part 1) --------Every time To add a message or two sentences to the home page, you have to upload the entire page again, which is really not worth it! So lazy people like Lan Feng...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn