第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

html 表單到 php 數(shù)組

html 表單到 php 數(shù)組

PHP
縹緲止盈 2023-05-12 14:17:46
我試圖將一個(gè)字符串作為用戶輸入的表單,并使用一組國(guó)家/地區(qū)檢查它是否是一個(gè)國(guó)家/地區(qū)。我現(xiàn)在收到此錯(cuò)誤:語(yǔ)法錯(cuò)誤,意外的“”(T_ENCAPSED_AND_WHITESPACE),期待“-”或標(biāo)識(shí)符(T_STRING)或變量(T_VARIABLE)或數(shù)字(T_NUM_STRING)<html><head></head><body><h1> Welcome to the Country Searcher </h1><form method="get">    <p><label for="guess">Input Guess</label>    <input type="text" name="guess" id="guess"/></p>    <input type="submit"/></form><?php    $countries = array("Afghanistan", "Albania", "Algeria", "American Samoa",                 "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda",                 "Argentina", "Armenia", "Aruba", "Australia", "Austria",                 "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh",                 "Barbados", "Belarus", "Belgium", "Belize", "Benin",                 "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina",                 "Botswana", "Bouvet Island", "Brazil",                 "British Indian Ocean Territory", "Brunei Darussalam",                 "Bulgaria", "Burkina Faso", "Burundi", "Cambodia",                 "Cameroon", "Canada", "Cape Verde", "Cayman Islands",                 "Central African Republic", "Chad", "Chile", "China",     if( in_array("$_GET['guess']",  $countries)) {        echo "Your country $_GET['guess'] is valid!";    } else {        echo "I'm sorry! You've entered an invalid string!";    }?></body></html>
查看完整描述

3 回答

?
手掌心

TA貢獻(xiàn)1942條經(jīng)驗(yàn) 獲得超3個(gè)贊

你可以通過使用使這更簡(jiǎn)單in_array()


在標(biāo)簽上 soecify 一個(gè)方法也是一個(gè)好主意<form>。默認(rèn)值可能是 GET,但如果您對(duì)其進(jìn)行編碼,那么您就是在自我記錄您的代碼。


<html>

<head></head>

<body>

<h1> Welcome to the Country Searcher </h1>

<form method="get">

    <p><label for="guess">Input Guess</label>

    <input type="text" name="guess" id="guess"/></p>

    <input type="submit"/>

</form>


<?php


    $countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", 

                "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", 

                "Argentina", "Armenia", "Aruba", "Australia", "Austria", 

                "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", 

                "Barbados", "Belarus", "Belgium", "Belize", "Benin", 

                "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", 

                "Botswana", "Bouvet Island", "Brazil", 

                "British Indian Ocean Territory", "Brunei Darussalam", 

                "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", 

                "Cameroon", "Canada", "Cape Verde", "Cayman Islands", 

                "Central African Republic", "Chad", "Chile", "China", 

                "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "France Metropolitan", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and Mc Donald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, The Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia (Slovak Republic)", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka", "St. Helena", "St. Pierre and Miquelon", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe");


    if( in_array($_GET['guess'],  $countries) {

        echo "Your country $_GET[guess] is valid!";

    } else {

        echo "I'm sorry! You've entered an invalid string!";

    }

?>


</body>

</html>


查看完整回答
反對(duì) 回復(fù) 2023-05-12
?
不負(fù)相思意

TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊

我終于想通了這個(gè)問題!我分配了一個(gè)變量GET并用這個(gè)變量代替了GET所有地方。這似乎解決了問題!



查看完整回答
反對(duì) 回復(fù) 2023-05-12
?
白衣非少年

TA貢獻(xiàn)1155條經(jīng)驗(yàn) 獲得超0個(gè)贊

$_GET是輸入?yún)?shù)數(shù)組(來自 url)。您必須按名稱取值:


$_GET['guess']


if($countries[$x]==$_GET['guess'])

并使用逗號(hào)連接字符串:


echo 'Your country ' . $_GET['guess'] . ' is valid!';


查看完整回答
反對(duì) 回復(fù) 2023-05-12
  • 3 回答
  • 0 關(guān)注
  • 199 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)