Home  >  Article  >  Backend Development  >  Website Setup PHP Personal Website Setup Lecture 2

Website Setup PHP Personal Website Setup Lecture 2

WBOY
WBOYOriginal
2016-07-29 08:33:46900browse

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 like A lazy guy 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, please 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 directly typing head.inc to download your For the source code, it is best to use php as the suffix, so that your server will intercept it for processing first, haha*/
echo "" <br>echo "The Road to Network Management"/ /If the title changes frequently, you can create a function. <br>echo ""
?>
This is a function block for writing html headers
/*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,'$}');//Excise the substring before '${' in $s
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 parameter is the number of characters
$a=substr($a,2);//Remove '${'
$lb=strlen($ b);$la=strlen($a);
$a=substr($a,0,$la-$lb);//Get the hyperlink part
$b=substr($b,1);// Remove '}'
$ta=strstr($a,"|");//Look for 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 novice, you should read an introductory book on HTML, otherwise it will be difficult to become a PHP master. Your function for processing strings may seem very simple at first, but with your clever use, it can do many beautiful things. In the next lecture, we can see the results of what we have prepared for most of the day, haha.

The above has introduced the website setting up. The second series of lectures on PHP personal website setting up includes the content of website setting up. I hope it will be helpful to friends who are interested in PHP tutorials.

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