我收到解析錯誤,我認爲這是因爲"time"
上的引號引起的。我怎樣才能把它當作一個整體的字符串呢?在PHP中跳轉引號
<?php
$text1= 'From time to "time" this submerged or latent theater in 'Hamlet'
becomes almost overt. It is close to the surface in Hamlet's pretense of madness,
the "antic disposition" he puts on to protect himself and prevent his antagonists
from plucking out the heart of his mystery. It is even closer to the surface when
Hamlet enters his mother's room and holds up, side by side, the pictures of the
two kings, Old Hamlet and Claudius, and proceeds to describe for her the true
nature of the choice she has made, presenting truth by means of a show.
Similarly, when he leaps into the open grave at Ophelia's funeral, ranting in
high heroic terms, he is acting out for Laertes, and perhaps for himself as well,
the folly of excessive, melodramatic expressions of grief.";
$text2= 'From time to "time"';
similar_text($textl, $text2, $p);
echo "Percent: $p%";
的問題是,我不能手動每個引號前加\
。這是我需要比較的實際文字。
手冊這裏:http://php.net/manual/en/language.types.string.php - 逃逸是相同的大多數其他C風格的語言。 – mario
實際上,上面屏幕截圖中的問題始於Hamlet這個詞之前的單引號,正如着色所暗示的那樣。由於字符串以單引號開頭,因此除了最後一個引號外,所有單引號內部都必須轉義。 因此,第一個變量聲明應該是這樣開始的: ''從時間到'時間'這個......在'哈姆雷特'中的劇院......' $ text2變量實際上很好。 – Goozak