• ベストアンサー

PHP実行時のエラーについて

質問よろしくお願いいたします。 PHP初心者なのですが、 サイト更新のし易さなどから ’ウェブランサー’というサイトのテンプレートを使わせて頂き、 試行錯誤しながら現在サイト構築を進めています。 動作確認にはXAMPPというフリーソフトを使っているのですが、 どうやらエラーが出ているようなのですが、 なにが原因なのかよくわかりません。 分かる方いらっしゃいましたら、教えて頂けないでしょうか? Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\public_html\index.php on line 2 これは何のエラーなのでしょうか? 自分なりにネットで調べても、英語サイトばかり引っ掛かり 原因が分からないでいます。 現在 public_html のフォルダーには、2つのファイルがありまして (ウェブランサーさんのテンプレートです。) どちらかが原因なのでしょうか? ■1つめのファイル(temp.php) <?php /***********************************/ // 使いまわす部品の用意 /***********************************/ // ドメイン(ファイルを設置するディレクトリまで定義) $domain = "http://".$_SERVER["HTTP_HOST"]."/"; // XML宣言 $xml_v = "<?xml version=\"1.0\" encoding=\"Shift_JIS\" ?>"; $body_text = "#000000"; $body_bg = "#FFFFFF"; $body_link = "#0000FF"; $body_vlink = "#0000FF"; $body_alink = "#0000AA"; $hr = "<hr style=\"border-color:#999999; border-style:solid;\" />"; $san = "<span style=\"color:#999999;\">…………………………</span>"; /***********************************/ // ヘッダーを定義 /***********************************/ $header = <<< TAGSET {$xml_v} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-Type" content="application/xhtml+xml; charset=Shift_JIS" /> <title>{$title}</title> <meta name="keywords" content="{$keyword}" /> <meta name="description" content="{$description}" /> <link rel="alternate" media="handheld" href="alternate_page.htm" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> <![CDATA[ a:link{color: {$body_link};} a:visited{color: {$body_vlink};} a:focus{color: {$body_alink};} ]]> </style> </head> <body text="{$body_text}" bgcolor="{$body_bg}" link="{$body_link}" vlink="{$body_vlink}" alink="{$body_alink}" style="color:{$body_text}; background-color:{$body_bg};"> TAGSET; /***********************************/ // フッターを定義 /***********************************/ $footer = <<< TAGSET {$hr} <div style="text-align:center; font-size:x-small;">(C)Sample.</div> </body> </html> TAGSET; ?> ■2つめのファイル(index.php) <?php if (ereg("DoCoMo", $_SERVER['HTTP_USER_AGENT'])) { header('Content-Type: application/xhtml+xml'); } $title = "このページのタイトル"; $keyword = "キーワード"; $description = "このページの説明文。"; include("./temp.php"); echo $header; ?> <!--=== CONTENTS ===--> コンテンツ部分を記述 <!--/=== CONTENTS ===--> <?php echo $footer; ?> これらのファイルをXAMPPで開くと、 以下のエラーがページ内に出ています。 Deprecated: Function ereg() is deprecated in C:\xampp\htdocs\public_html\index.php on line 2 コンテンツ部分を記述 -------------------------------------------------------------------------------- (C)Sample. 本来は、コンテンツ部分を記述がページ文頭にこないと おかしいと思うのですが…。 これの原因分かる方いらっしゃいますか?

  • rs77
  • お礼率100% (24/24)
  • PHP
  • 回答数1
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • tany180sx
  • ベストアンサー率63% (239/379)
回答No.1

> これは何のエラーなのでしょうか? Function ereg() is deprecated => 関数 ereg は 廃止予定 deprecated〔仕様などが〕廃止される可能性がある、廃止予定の、将来のサポートが保証されない(ので使用すべきでない)、非推奨の◆仕様が改定されたが、後方互換のために以前の方式も当面使えるようにしてある場合など > 自分なりにネットで調べても、英語サイトばかり引っ掛かり原因が分からないでいます。 Deprecated: Function ereg() is deprecated までで検索すればすぐ見つかるでしょ。 C:\xampp\htdocs\public_html\index.php はあなたの環境なので検索しなくていいです。 > 現在 public_html のフォルダーには、2つのファイルがありましてどちらかが原因なのでしょうか? index.php on line 2 と書いてあります。 index.php の 2行目が原因である可能性が高いということです。 > if (ereg("DoCoMo", $_SERVER['HTTP_USER_AGENT'])) { if (preg_match("/DoCoMo/", $_SERVER['HTTP_USER_AGENT'])) { などに関数を変更すればおさまります。 あんまり便利そうには見えませんが..

rs77
質問者

お礼

おはようございます。 お礼遅くなってしまい、大変申し訳ありません… ご指摘いただいた箇所を修正しましたところ、 エラーは無事に解消することができました。 どうもありがとうございます^^

関連するQ&A

  • ドコモだけPHPを介すとスタイルシートが効かない

    こんにちは。 今、携帯サイトを作成しております。 その中で不思議な現象があるため、もしご存じの方がいらっしゃいましたら、ご助言頂けますと幸いです。 まずソースをご覧ください。 <?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE html PUBLIC "-//i-mode group (ja)//DTD XHTML i-XHTML(Locale/Ver.=ja/1.0) 1.0//EN" "i-xhtml_4ja_10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="application/xhtml+xml;charset=Shift_JIS" /> <meta http-equiv="content-style-type" content="text/css" /> <title>TEST</title> </head> <body style="color:#ff0000;"> red?<br /> <span style="color:#0000ff;">blue?</span> </body> </html> 上記のソースを、例えば「test.xhtml」という名前で保存して、PCと携帯3キャリアで確認すると、ちゃんと文字色の指定が効きます。 しかし、同じソースを下記のソースではさみ、phpを介して表示させようとすると、ドコモだけスタイルシートが効かなくなり、文字色が黒になってしまいます。 <?php echo ' (ここに上記ソースをコピー) '; ?> ※拡張子は.phpでも.xhtmlでも同じ現象でした。 PHPを介してもスタイルシートが効くようにするには、どのようにしたらよいでしょうか? よろしくお願いいたします。

    • ベストアンサー
    • PHP
  • SafariでPHPソースがそのまま表示される

    Safariでindex.phpを開くとソースコードがそのまま表示されてしまいます。 拡張子をphpとしているだけでソース内にはphpスクリプトは記述しておりません。 なぜでしょうか? ※ファイル名をindex.htmlに変えると正しく表示されます。 Windows 7 Home Premium 64bit Safari5.1.5 ソースコードのエンコーディング:utf-8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="content-script-type" content="text/javascript" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <title>テストtitle> </head> <body> <h1>テストページ</h1> </body> </html>

  • CSSのアドバイスをお願いいたします。

    <?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <meta name="robots" content="noindex,nofollow,noarchive" /> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> .r { color : #407133; } .k { color : #336070; } .t { color : #454580; } .s { color : olive; } p { color : #222222; } body { background-color:#e0ffe0; } a:link { color : #0000ff; } a:visited { color : #003333; } a:hover { color : #660000; } a:active { color:#660066; </style> <meta http-equiv="Content-Script-Type" content="text/javascript" />の1行を加えてみました。 この場合の記述の是非。 また記述すべき個所は合っているのでしょうか。

    • ベストアンサー
    • HTML
  • CSSのチェックをお願いします。

    <?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <meta name="robots" content="noindex,nofollow,noarchive" /> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> .r { color : #407133;} .t { color : #454580;} p { color : #222222;} body { background-color:#e0ffe0;} a:link { color : #0000ff;} a:visited { color : #003333;} a:hover { color : #660000;} a:active { color:#660066;} 1.改行に何か意味はあるのでしょうか? 2.記述の順番や付け足し、削除すべき項目がありましたら、お願いいたします。

    • ベストアンサー
    • HTML
  • <title>~<title>部分にPHP読み込み

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <title>●●●●●●</title> <meta http-equiv="content-script-type" content="text/javascript" /> </head> <body> ~ 上記<title>●●●●●●</title>部分の、●●●●●●にtitle.phpの内容を挿入したく、 <?php require("title.php"); ?> と記述したのですが、エラーが出てしまいます。 title.php単体では正常に文字が表示されます。 どのように記述したら良いか、どなたかご教授いただけないでしょうか。 宜しくお願い致します。

    • ベストアンサー
    • PHP
  • phpを外部呼出で表示されない

    自分はモバイルサイトを運営しておりまして、 CGIのカウンターからPHPのカウンターに変更しようと思いました。 そしてハンターリンク(http://ezch.org/)さんの 絵文字カウンタが良いと思い、早速設置しました。 しかしインクルードで呼び出しても、 携帯andパソコンで表示されません。 PHPファイル自体は弄ってません。 鯖はXREAの137鯖です。 以下が呼出部分までのソースです。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <META http-equiv="Content-Style-Type" content="text/css"> <META http-equiv="pragma" content="no-cache" /> <META http-equiv="cache-control" content="no-cache" /> <TITLE>auMusic</TITLE> <STYLE TYPE="text/css"> <!-- body {background:fixed url(p/logo.jpg) #ffffff no-repeat bottom right;} body {border-style:solid;border-color:#FF8C00;border-width:5px;} a:hover { color:##0000ff; } A{text-decoration:none;} --> </STYLE> </HEAD> <BODY bgcolor="#ffffff" vlink="#ff0000" alink="#ff0000" link="#ff0000"> <CENTER> <HR width="100%" size="6" noshade color="red"> <div align="center"><IMG src="au_Music.gif" border="0"></div> </CENTER> <HR width="100%" size="6" noshade color="red"> <HR align="center" width="95%" size="1"> <?include("count.php");?>

    • ベストアンサー
    • PHP
  • 背景画像を貼り付けるhtmlコードはどこに貼り付ければいいんですか?

    コードはわかるんですが、どこに貼り付けたらいいのか教えてください。 ようするに最初は <html> <head> <meta http-equiv="content-type" content="text/html; charset=EUC-JP"> <title>無題</title> <meta name="generator" content=" 6.0.0.49"> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="red"> <p style="line-height:150%;">&nbsp;</p> </body> </html> となっているんですが、このなかのどこに挿入したらいいのかおしえていただきたいです。

  • xhtmlのスタイルシートについて

    <?xml version="1.0" encoding="Shift_JIS"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <meta name="robots" content="noindex,nofollow,noarchive" /> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> t { color : 407133; k { color : 337060; r { coior : 454580 &gt; </style> ↑どこか間違っているところがありましたら教えてください。 <span class="#407133">てすと</span> 文字色が変わりません。 どなたか指摘願います。

  • phpのダウンロード画面が出てしまう

    IE6からphpにアクセスするとダウンロード画面が出てきてしまいます。 ダウンロード画面を出さないようにするにはどうすればいいでしょうか。httpd.confは編集できない環境です。 .htaccessは下記のどちらにしてもDL画面が出てきます。 AddType application/x-httpd-php .xhtml AddType application/xhtml+xml .php index.php; <?php header("Content-Type: application/xhtml+xml"); echo "<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" > <head> <meta http-equiv="ContentType" content="application/xhtml+xml" /> <meta content="i-mode7_FOMA" /> <title>タイトル</title> </head> <body> <?php readfile("./numbers3/n3temp.txt"); ?> </body> </html>

    • ベストアンサー
    • CSS
  • Shift_JISのことろをすべてsjisに

    しても大丈夫でしょうか? たとえば以下のように書いて大丈夫でしょうか? 本来どのように書くべきでしょうか? <?xml version="1.0" encoding="sjis"?>のsjisと <meta http-equiv="content-type" content="application/xhtml+xml; charset=sjis"/> のsjisの2箇所です。 <?xml version="1.0" encoding="sjis"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"> <head> <meta http-equiv="content-type" content="application/xhtml+xml; charset=sjis"/> <meta http-equiv="content-style-type" content="text/css"/> <meta http-equiv="content-script-type" content="text/javascript"/> <title>sjis</title> </head> <body> <p>これは文字化けのテストです</p> </body> </html>

    • ベストアンサー
    • HTML

専門家に質問してみよう