$ words 변수는 내 페이지가 www.rae.es에서 가져 오는 의미를 찾는 스페인어 단어입니다. 일부 스페인어 단어는 급한 악센트 (á é ú í ó)를 사용합니다. 사용자가 "baúl"을 입력하면 인식하지 못합니다. 나는 "ba % FAl"(작동)로 인코딩하기 위해 url_encode ($ words) 함수를 사용해야한다는 것을 알고 있지만 작동하지 않습니다. 다음은 PHP 코드의 대부분은 다음과 같습니다 스타일 교체URL 인코딩이 작동하지 않습니다.
감사 위의 코드에
<?php
// create an array of requests that we want
// to load in the url.
$words = array('word','word0','word1','word2','word3','word4','word5');
function url_encode($string){
return urlencode(utf8_encode($string));
}
// we'll use this later on for loading the files.
$baseUrl = 'http://lema.rae.es/drae/srv/search?val=';
// string to replace in the head.
$cssReplace = <<<EOT
<style type="text/css">
//bla bla bla
</style>
</head>
EOT;
// string to remove in the document.
$spanRemove = '<span class="f"><b>.</b></span>';
$styleRemove =
// use for printing out the result ID.
$resultIndex = 0;
// loop through the words we defined above
// load the respective file, and print it out.
foreach($words as $word) {
// check if the request with
// the given word exists. If not,
// continue to the next word
if(!isset($_REQUEST[$word]))
continue;
// load the contents of the base url and requested word.
$contents = file_get_contents($baseUrl . $_REQUEST[$word]);
// replace the data defined above.
$contents = str_replace('</head>', $cssReplace, $contents);
$contents = str_replace($spanRemove,"", $contents);
// print out the result with the result index.
// ++$resultIndex simply returns the value of
// $resultIndex after adding one to it.
echo '<div id="result" style="
margin-top:-80px;
overflow:scroll;
width:800px;
height:150px;
border: 1px solid #000000;
border-radius: 15px;
background-opacity: 0.5;
background: #047C8F;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
box-shadow: inset 0px 3px 13px #000000;
-moz-box-shadow:
0px 3px 13px rgba(000,000,000,0.5),
inset 0px 0px 13px rgba(0,0,0,1);
-webkit-box-shadow:
0px 3px 13px rgba(000,000,000,0.5),
inset 0px 0px 13px rgba(0,0,0,1);
', (++$resultIndex) ,'">', $contents ,
'</div>',
'<br/>',
'<br/>',
'<br/>',
'<br/>',
'<br/>';
}
?>
초점!
당신이 작동하지 않습니다 무슨 뜻으로이
? 실제로 url_encode를 호출하고 있습니까? 그것처럼 보이지 않는다. –