PHP はテキスト ファイルのページング関数を簡単に実装できます
PHP はテキスト ファイルのページング関数を簡単に実装できます
<meta http-equiv="Content-type" content="text/html"> <title>Paging</title> <style><span style="color: #000000;"> a{ padding:<span style="color: #000000;">20px; } </style><span style="color: #000000;">php</span><span style="color: #008000;">//</span><span style="color: #008000;"> 中文字符处理</span><span style="color: #0000ff;">function</span> m_substr(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$start</span>, <span style="color: #800080;">$length</span><span style="color: #000000;">){ </span><span style="color: #800080;">$str_length</span> = <span style="color: #800080;">$start</span> + <span style="color: #800080;">$length</span>; <span style="color: #008000;">//</span><span style="color: #008000;"> 获取截取总长度</span> <span style="color: #800080;">$tmp_str</span> = ""<span style="color: #000000;">; </span><span style="color: #0000ff;">for</span>(<span style="color: #800080;">$i</span>=0;<span style="color: #800080;">$i</span>$str_length;<span style="color: #800080;">$i</span>++<span style="color: #000000;">){ </span><span style="color: #0000ff;">if</span>(<span style="color: #008080;">ord</span>(<span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1)) == 0x0a<span style="color: #000000;">){ </span><span style="color: #800080;">$tmp_str</span> .= "<br>"<span style="color: #000000;">; } </span><span style="color: #0000ff;">if</span>(<span style="color: #008080;">ord</span>(<span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1))>0xa0<span style="color: #000000;">){ </span><span style="color: #800080;">$tmp_str</span> .= <span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 2<span style="color: #000000;">); </span><span style="color: #800080;">$i</span>++<span style="color: #000000;">; }</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{ </span><span style="color: #800080;">$tmp_str</span> .= <span style="color: #008080;">substr</span>(<span style="color: #800080;">$str</span>, <span style="color: #800080;">$i</span>, 1<span style="color: #000000;">); } } </span><span style="color: #0000ff;">return</span> <span style="color: #800080;">$tmp_str</span><span style="color: #000000;">;}</span><span style="color: #008000;">//</span><span style="color: #008000;"> 传参处理</span><span style="color: #0000ff;">if</span>(<span style="color: #0000ff;">isset</span>(<span style="color: #800080;">$_GET</span>['page'<span style="color: #000000;">])){ </span><span style="color: #800080;">$page</span> = <span style="color: #800080;">$_GET</span>['page'<span style="color: #000000;">];}</span><span style="color: #0000ff;">else</span><span style="color: #000000;">{ </span><span style="color: #800080;">$page</span> = 1<span style="color: #000000;">;}</span><span style="color: #800080;">$counter</span> = <span style="color: #008080;">file_get_contents</span>("example.txt"<span style="color: #000000;">);</span><span style="color: #800080;">$length</span> = <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$counter</span><span style="color: #000000;">);</span><span style="color: #800080;">$page_count</span> = <span style="color: #008080;">ceil</span>(<span style="color: #800080;">$length</span>/400<span style="color: #000000;">);</span><span style="color: #800080;">$pre_str</span> = m_substr(<span style="color: #800080;">$counter</span>, 0, (<span style="color: #800080;">$page</span>-1)*400<span style="color: #000000;">);</span><span style="color: #800080;">$now_str</span> = m_substr(<span style="color: #800080;">$counter</span>, 0, <span style="color: #800080;">$page</span>*400<span style="color: #000000;">);</span><span style="color: #0000ff;">echo</span> <span style="color: #008080;">substr</span>(<span style="color: #800080;">$now_str</span>, <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$pre_str</span>), <span style="color: #008080;">strlen</span>(<span style="color: #800080;">$now_str</span>)-<span style="color: #008080;">strlen</span>(<span style="color: #800080;">$pre_str</span><span style="color: #000000;">));</span><span style="color: #0000ff;">echo</span> "<br><br>"<span style="color: #000000;">;</span><span style="color: #0000ff;">echo</span> "当前页".<span style="color: #800080;">$page</span>."/".<span style="color: #800080;">$page_count</span><span style="color: #000000;">;</span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=1">Index</a>"<span style="color: #000000;">;</span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$page</span>>1<span style="color: #000000;">){ </span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=%22.(<span%20style=%22color:%20#800080;%22>%24page</span>-1).%22">Pre</a>"<span style="color: #000000;">;}</span><span style="color: #0000ff;">if</span>(<span style="color: #800080;">$page</span>$page_count<span style="color: #000000;">){ </span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=%22.(<span" style="color: #800080;">$page+1).">Next</a>"<span style="color: #000000;">;}</span><span style="color: #0000ff;">echo</span> "<a href="index.php?page=<span" style="color: #800080;">$page_count>End</a>"<span style="color: #000000;">;</span>?>

phpssionscanStorestrings、numbers、arrays、andobjects.1.strings:textdatalikeusernames.2.numbers:integersorfloatsforcounters.3.arrays:listslikeshoppingcarts.4.objects:complextructuresthataresialized。

tostartaphpsession、outsession_start()atthescript'sbeginning.1)placeitbe foreanyouttosetthesscookie.2)usesionsionsionsionserdatalikelogintatussorshoppingcarts.3)再生セッションインドストップレベントフィックスアタック

セッション再生とは、新しいセッションIDを生成し、セッション固定攻撃の場合にユーザーが機密操作を実行するときに古いIDを無効にすることを指します。実装の手順には次のものが含まれます。1。感度操作を検出、2。新しいセッションIDを生成する、3。古いセッションIDを破壊し、4。ユーザー側のセッション情報を更新します。

PHPセッションは、アプリケーションのパフォーマンスに大きな影響を与えます。最適化方法には以下が含まれます。1。データベースを使用してセッションデータを保存して応答速度を向上させます。 2。セッションデータの使用を削減し、必要な情報のみを保存します。 3.非ブロッキングセッションプロセッサを使用して、同時実行機能を改善します。 4.セッションの有効期限を調整して、ユーザーエクスペリエンスとサーバーの負担のバランスを取ります。 5.永続的なセッションを使用して、データの読み取り時間と書き込み時間を減らします。

phpsesionsareserver-side、whilecookiesareclient-side.1)Sessionsionsionsoredataontheserver、aremoresecure.2)cookiesstoredataontheclient、cookiestoresecure、andlimitedinsizeisize.sesionsionsionivationivationivationivationivationivationivationivate

phpidentifiesauser'ssessionsingsinssessionCookiesIds.1)whensession_start()iscalled、phpgeneratesauniquesidstoredsored incoookienadphpsessidontheuser'sbrowser.2)thisidallowsphptortorieSessiondatadata fromthata

PHPセッションのセキュリティは、次の測定を通じて達成できます。1。session_regenerate_id()を使用して、ユーザーがログインまたは重要な操作である場合にセッションIDを再生します。 2. HTTPSプロトコルを介して送信セッションIDを暗号化します。 3。Session_Save_Path()を使用して、セッションデータを保存し、権限を正しく設定するためのSecure Directoryを指定します。

phpsessionFilesToredInthededirectoryspecifiedBysession.save_path、通常/tmponunix-likesystemsorc:\ windows \ temponwindows.tocustomizethis:1)uesession_save_path()tosetaCustomdirectory、ensuringit'swritadistradistradistradistradistra


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

SublimeText3 中国語版
中国語版、とても使いやすい

Dreamweaver Mac版
ビジュアル Web 開発ツール

ホットトピック









