עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

str_replace שמסרב לעבוד (PHP)

Featured Replies

פורסם

דף php :

  include_once("lang.php");

$_page = file_get_contents("index.html");

foreach($_lang as $key => $value)
{
$_page = str_replace($key , $value , $_page);

}

include_once("dbconnect.php");




mysql_query("SET NAMES 'hebrew'");



//contents
session_start();
if(isset ($_SESSION['islogged']) && $SESSION['islogged'] ==TRUE)
{


}
else
{
$rep = " <form method=\"POST\" action=\"check.php\" enctype=\"multipart/form-data\">
user : <input name=\"user\" type=\"text\"></input> <br />
password : <input name=\"pass\" type=\"password\"></input> <br />
<input type = \"submit\" value = \"send\" <br />
</form>";
$_page = str_replace(" __index_content__ ",$rep, $_page);
}

mysql_close($connection);


echo $_page ;

עמוד ה- Html שנטען :



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/url]
<html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
<head>
<title>__title__</title>
<meta http-equiv="Content-Language" content="__content_lang__" />
<meta http-equiv="Content-Type" content="text/html; charset=__charset__" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body dir="__dir__">

<div id="wrap">

<div id="header">
<h1><a href="__link__">__website_name__</a></h1>
<h2>__subheader__</h2>
</div>



<div id="content">
<div class="left">
__index_content__

<img src="images/pic.jpg" alt="__website_name__" style="border: 3px solid #ccc;" />
<br /><br />

</div>
<div class="articles">



</div>
</div>

<div class="right">

<h2>__pages__</h2>
<br />
__pages_list__



</div>
<div style="clear: both;"> </div>
</div>

<div id="footer">
<a href="__prog_link__" target="_blank">__site_programmer__</a>
</div>
</div>

</body>
</html>

ה- str_replace מסרב לעבוד (כם כשמורידים את ה if-else והכל) ה- str_replace שנמצא בתוך ה- foreach עובד , והדף מודפס כפלט.

פורסם

תראה לנו את התוכן של המשתנה $_lang שלך (ידוע שזה מערך).

כמו כן השורה הזו:

$_page = str_replace(" __index_content__ ",$rep, $_page);

לא תעבוד לך כי בקובת HTML אין לך רווח אחרי המחרוזת שאתה רוצה להחליף, תשנה את זה ל:

$_page = str_replace("__index_content__",$rep, $_page);

אני רק יכל לשער שזו הבעיה גם עם הדברים האחרים.

פורסם
  • מחבר

הצלחתי תודה :)

למרות שאני עדיין לא מאמין שהבעיה הייתה בגלל רווח

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.