PHP 基礎測試題(6~10)

來源:互聯網
上載者:User
網眼 2009-03-19 22:09:46 回複 置頂 修改 刪除
6. What is the output of the following script?$a = 10;$b = 20;$c = 4;$d = 8;$e = 1.0;$f = $c + $d * 2;$g = $f % 20;$h = $b - $a + $c + 2;$i = $h << $c;$j = $i * $e;print $j;?>A.128B.42C.242.0D.256E.342 7. Which values should be assigned to the variables $a, $b and $c in order for the followingscript to display the string Hello, World!?$string = "Hello, World!";$a = ?;$b = ?;$c = ?;if($a) {if($b && !$c) {echo "Goodbye Cruel World!";} else if(!$b && !$c) {echo "Nothing here";}} else {if(!$b){if(!$a && (!$b && $c)) {echo "Hello, World!";} else {echo "Goodbye World!";}} else {echo "Not quite.";}}?>A.False, True, FalseB.True, True, FalseC.False, True, TrueD.False, False, TrueE.True, True, True 8. What will the following script output?$array = '0123456789ABCDEFG';$s = '';for ($i = 1; $i < 50; $i++) {$s .= $array[rand(0,strlen ($array) - 1)];}echo $s;?>16PHP Programming BasicsA.A string of 50 random charactersB.A string of 49 copies of the same character, because the random number generator has not been initializedC.A string of 49 random charactersD.Nothing, because $array is not an arrayE.A string of 49 ‘G’ characters 9. Which language construct can best represent the following series of if conditionals?if($a == 'a') {somefunction();} else if ($a == 'b') {anotherfunction();} else if ($a == 'c') {dosomething();} else {donothing();}?>A.A switch statement without a default caseB.A recursive function callC.A while statementD.It is the only representation of this logicE.A switch statement using a default case 10. What is the best way to iterate through the $myarray array, assuming you want to modify thevalue of each element as you do?$myarray = array ("My String","Another String","Hi, Mom!");?>A.Using a for loopB.Using a foreach loopC.Using a while loopD.Using a do…while loopE.There is no way to accomplish this goal
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.