PHP Exercises-Four calculatorI. Focus: The practice of JS DOM elementsTwo. The code is as follows: Four calculator: " >Three. Page output:PHP Exercises-Four Calculator
() {}}/* $db = mysql::getins ();p Rint_r ($db), $sql = "SELECT * FROM Art limit 5";p Rint_r ($db- >getall ($sql)); * *init.phpWeb site initialization File/** Magic method __file__ The current absolute path file role: Responsible for the current site root directory introduced so that the page needs to file *///root on behalf of the site's path define (' ROOT ', str_replace (' \ \ ', '/', Str_replace (' includes\init.php ', ' ', __file__) '); require (ROOT. ') Includes/conf.class.php '); require
Program 6.title: Suppose someone has 100,000 of cash, every intersection need to pay the rules for the payment when he is more than 50,000 per cent of the amount of cash to be 5, if the cash is less than or equal to 50,000 per 5,000. Ask how many times this person can pass this intersection.1 $money= 100000;2 $i= 0;3 while($money>= 5000) {4 if($money> 50000) {5 $money*= 95/100;6}Else if($money) {7 $money-= 5000;8 }9 $i++;Ten } One Echo' Can pass '.$i. ' Sub-junction
$max=$x>$y?$x:$y;6 $max=$z>$max?$z:$max;7 8 Echo' Max number: '.$max.‘ Program 3.title: Print out all the "daffodils", the so-called "Narcissus number" refers to a three-digit number, its number of cubes and equal to the number itself.1 $j= 0;//Number of Bits2 $k= 0;//number of 10-bit3 $l= 0;//number of the hundred4 for($i= 100;$i$i++){5 $j=$i% 10;6 $k= ($i% 100-$j)/10;7 $l= ($i-$i% 100)/100;8 if($i== ($j*$j*$j+$k*$k*$k+$l*$l*$l)) {9 Echo $i. ‘ ‘;Ten } One}Program
PHP exercises-print hollow diamond with for Loop
Idea: 1. Write the code and print the solid pyramid.
2. modify the code and empty the pyramid.
3. modify the code and reverse the pyramid
4. Modify the reversed code and empty the pyramid.
5. modify the code and parameterize the specific number.
1. Write the code to print the pyramid of solid gold:
2,
2. Improve code and empty the pyramid
3. modify the co
PHPclassTalker {Private $data= ' Hi '; Public function Get () {//The return value points to a content, here is the content that points to $data,//test: If the function name is not preceded by , the code executed below final output: Hihihihi return $this-data; } Public functionout () {Echo $this-data; } } $aa=Newtalker (); $aa-out (); $b= $aa->get ();//this actually points to the contents of the $data, changing the value of the $d to change the contents of the $data
PHP template Smarty ExercisesI. Practice EnvironmentSmarty_inc for Smarty Lib librarysmarty_inc.php Importing library filesTwo. Smarty Variable exercise$smarty->assign Setting Transfer variables$smarty->display Loading templatesindex.phpIndex.htmlAccess localhost/smarty/index.php go directly to index.htmlThis is my home!Three. Smarty Array Exercisesindex.phpIndex.htmlFour. Smarty two-dimensional array exercisesindex.phpIndex.htmlFive. Smarty Scalar op
A few days ago in Baidu know inside see a netizen asked how to make a small program: in PHP language design a small program, calculate today to the number of days to the next month, all output these days, and make daily date in three colors cycle display, set three forms, let the user choose font Color, The three colors are then looped out to reflect those dates on the output . Today just have time to make it out for him, this actually does not have a
When assigning values to a SESSION, note that the first line of the PHP code in the value assignment page must be written session_start ();To assign a value page:PHP Session_Start (); // Be sure to remember to use the session when each page should be added regardless of the value or the assignment page at the beginning to add: session_start ();//Session Control//http Protocol//http protocol called stateless protocol based on TCP protocol// Session fe
);d eletearyelement ($arr, 2); Echo ' /** * 13, delete the number of primes in the array to form a new array */function Filtfun ($val) {//Custom filter prime function $flag = true;//To determine if the prime if (Is_int ($val)) {if ($val /** * 14, the Write function checks whether an element exists in the array (not directly using In_array) */function Exsitele ($arr, $value) {if (!) ( Is_array ($arr) count ($arr) >0) {return false;} foreach ($arr as $key = + $val) {if ($val = = $value) {return t
=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8C/48/wKiom1hnzuPQQz5eAAHkbmJaH_M121.png-wh_500x0-wm_3 -wmp_4-s_3996861951.png "title=" 2016-12-31_232841.png "alt=" Wkiom1hnzupqqz5eaahkbmjah_m121.png-wh_50 "/>Note: the preg_match function is used for regular judgment if (!preg_match ($repat, $pass))The echo "password format is incorrect"else if ($pass! = $zaicipass) Determine if the password is consistent two times, if inconsistentecho "Two times password Inconsistent"The Header,die function works a
=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8C/48/wKiom1hnzuPQQz5eAAHkbmJaH_M121.png-wh_500x0-wm_3 -wmp_4-s_3996861951.png "title=" 2016-12-31_232841.png "alt=" Wkiom1hnzupqqz5eaahkbmjah_m121.png-wh_50 "/>Note: the preg_match function is used for regular judgment if (!preg_match ($repat, $pass))The echo "password format is incorrect"else if ($pass! = $zaicipass) Determine if the password is consistent two times, if inconsistentecho "Two times password Inconsistent"The Header,die function works a
$this->us=$US; the $ZJG=$this->us->jiage (); + $user=$this->us->user_s (); - Echo $user. ': Original price '.$yjg. ', present price '.$ZJG*$yjg." ; the Bayi } the the } - - classHdprcextendsrun{//inherit run shows different user prices the functionSp$HD){ the $this->buy (ACTIVE::SHOWACTIVEPRC ($HD),Neworduser); the $this->buy (ACTIVE::SHOWACTIVEPRC ($HD),Newvipuser); the $this->buy (ACTIVE::SHOWACTIVEPRC ($HD),Newsvipuser); -
Requirements: Write a class that can be arithmetic, or can be calculated as a rectangular area
1. ProcedureViewcount.html Count.class.phpprintcount.php 2. Results
Requirements: the arithmetic and area operators into one, the main menu lets the user choose to do arithmetic or area calculation
1. ProcedureViewcount1.html use a little javascript knowledgeCount.class.php class file does not changeprintcount1.php2. Results PH
Enter 10 person's name scores, print from big to small sort1PHP2?>34Name: 5Score: 6Name: 7Score: 8Name: 9Score: TenName: OneScore: AName: -Score: -Name: theScore: -Name: -Score: -Name: +Score: -Name: +Score: AName: atScore: - - - - - //define the array CJ, receive the results in the text box; in $CJ[0]=$_post[' Cj1 ']; - $CJ[1]=$_post[' CJ2 ']; to $CJ[2]=$_post[' Cj3 ']; + $CJ[3]=$_post[' Cj4 ']; - $CJ[4]=$_post[' Cj5 ']; the $CJ[5]=$_post[' Cj6
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.