• ベストアンサー

Smarty/pluginsファルダ内 function.***.php ファイルのデバッグ

Smarty pluginsファルダ内にあるfunction.***.phpファイルのデバッグはどうやればよいのでしょうか? やりたいこと。 function.***.phpファイル内の変数内容を、処理の途中ごとで確認したい。 出力時ではなくて、このファイル内の処理の途中の変数の値を見たいのですが.. print $var_name;とやっても何も表示されませんでした。

  • re999
  • お礼率61% (476/777)
  • PHP
  • 回答数1
  • ありがとう数0

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

  • ベストアンサー
  • BellBell
  • ベストアンサー率54% (327/598)
回答No.1

Smarty出力の絡みか?出力したはずの変数のダンプが見えないって事、ときどき発生しますね。 実際にはSmartyが原因なのか、それとも他の原因か私自身詰め切れていませんが。 出力されないっぽい現象発生した場合、error_log関数使ってファイルに出力してるので。 http://jp.php.net/manual/ja/function.error-log.php

関連するQ&A

  • PHPのデバッグ方法

    PHPでデバックする方法を探しています。 var_dumpやprint_rで変数を表示させる以外に、効率よくデバッグできる方法が知りたいです。 GUIで値がウォッチできたり、ソースのバージョン管理できるような ソフトはあるのでしょうか?

    • ベストアンサー
    • PHP
  • PHP+smartyで困っております。

    今までASPで開発をおこなっておりましたが、PHPを勉強中のPHP初心者です。 さて、smartyでの表示ですがどうしてもうまくいきません。 $smarty->assign("info",manage::getinfo(18,$a_db)); $smarty->display("comp_regist2.tpl"); で、smartyを利用したいのですが、値が表示されません。 {debug} にて下記値がわたされているのは確認しております。 Array (1) 0 => manage Object (2) _id => 18 _company_name => AAA店 tplファイルに、下記内容を記入してみましたが、表示されません。 {$info._id|escape}<hr> {$info._company_name|escape}<hr> {$_id}<hr> {$_company_name}<hr> {debug} {$info._id} {$info._company_name} 丸二日、、、こんなところではまっております。 お教えいただけませんでしょうか?

    • ベストアンサー
    • PHP
  • SMARTYのエラーについて。について。

    今度業務でPHPをやる事になったので手始めにSmartyを使って簡単なアプリケーションを作ってみようと思ったのですが、最初の段階でいきなりつまづいてしましました。 具体的には、サンプルサイトからコピーした以下の様なphp&テンプレートを動かすと決まって次のエラーになります。 【/var/www/html/test/index.php】 <?php require_once('/var/www/smarty/libs/Smarty.class.php'); $smarty = new Smarty; $smarty->assign('name', 'test'); $smarty->display('index.tpl'); ?> 【/var/www/html/test/templates/index.tpl】 <html> <head> <title>User Info</title> </head> <body> 名前:{$name}<br> </body> 【エラー】 Warning: preg_match() [function.preg-match]: Compilation failed: repeated subpattern is too long at offset 18454 in /var/www/smarty/libs/Smarty_Compiler.class.php on line 454 ちなみに環境は以下の通りです。 OS:CentOS5.2 web:apache2.2.3 php:5.1.6 Smarty:2.6.21 同様の基本的なサンプルを他にもいくつか実行しましたが、結果は上記エラーと全く同一のものしか出力されません… 同じ症状が出て対応された方がいらっしゃいましたら回答の程よろしくお願い致します。

    • ベストアンサー
    • PHP
  • Smartyの設定について

    FedoraCore 4 MySQL 4.1.14 PHP 5.0.4    を使ってます。 Smartyを入れようと思い、Web上でいろいろ調べてやっているのですが、うまく動きません。 解凍したSmartyをフォルダごと /usr/local/lib/php/Smarty に移動し、 /etc/php.ini の中のinuclude_pathを include_path = ".:/usr/local/lib/php:/usr/local/lib/php/Smarty" としました。 そして、Demoフォルダを /var/www/html/demo/に移動してブラウザ上でdemoを見ているのですが、下記のエラーがでてしまいます。 Warning: main(/usr/local/lib/php/Smarty/Smarty.class.php) [function.main]: failed to open stream: No such file or directory in /var/www/html/demo/index.php on line 3 Fatal error: main() [function.require]: Failed opening required '/usr/local/lib/php/Smarty/Smarty.class.php' (include_path='.:/usr/local/lib/php/Smarty') in /var/www/html/demo/index.php on line 3 エラーの内容を見てみると Smarty.class.phpを呼び出すには /usr/local/lib/php/Smarty/lib/Smarty.class.phpとなっていないとおかしいと思うのですが、このあたりどう設定してよいのかわかりません。 Smartyの基本的な設定を何卒ご教授ください。

    • ベストアンサー
    • PHP
  • 【php】Smartyを使うとどの様な利点があるか

    phpによるWEB制作で 現在 デザイナーが作ったデザインを1枚のHTMLファイルに コーディングまでしてもらって それを、プログラマーがバラバラに分解、インクルード、データベースとの組み込みなどを 加えていくという工程を行っています。 以前からプログラマーとデザイナーが作業を分担しやすいという Smartyというものに興味があったのですが、 Smartyも、デザインをパーツごとにわけて変数化するということですよね? インクルード化や、phpの変数に納めるのと どう違うのか また、動的ページは条件によって1枚のページがいろいろ変化するわけですから 結局デザイナーにもある程度のプログラムを意識した作成が求められるように思えます。 Smartyを導入すると、どのような利点があるのでしょうか。

    • ベストアンサー
    • PHP
  • PHPとSmartyの関連について

    PHPとSmartyの関連について PHPからSmartyに出力しているのですが中身がNULLになります。 データベースアクセスにはPDOを使用しています。 PHPソース DBアクセス $SQL = "select ITEM_ID from ITEM_TBL limit 0, 3"; $STMT = $GLOBALS["PDO"] -> query($SQL); $ROW = $STMT -> fetchAll(PDO::FETCH_ASSOC); Smartyでアサイン $smarty -> assign("ITEM_LIST", $ROW); Smartyソース <table> {{foreach from=$ITEM_LIST item=LIST}} <tr> <td>{{$LIST.ITEM_ID}}</td> </tr> {{/foreach}} </table> のような感じでページ出力したいのですが、表示をすると中身がNULLでした。 PHP側で var_dump($ROW); を行うと array(3) { [0]=> array(1) { ["ITEM_ID"]=> string(1) "1" } [1]=> array(1) { ["ITEM_ID"]=> string(1) "2" } [2]=> array(1) { ["ITEM_ID"]=> string(1) "3" } } 中身が配列で格納されています。 smarty側で {$ITEM_LIST|@var_dump} を行うと array(3) { [0]=> NULL [1]=> NULL [2]=> NULL } でした。 いろいろとやってみたのですが、わからなくなってしまったので どなたかご教授いただけませんでしょうか。よろしくお願いします。

    • 締切済み
    • PHP
  • Smarty3のリソース・プラグイン

    Smarty3のリソース・プラグインについて Smarty3(3.0.9)でリソース・プラグインを行うと以下エラーが出力され、データベース内のテンプレートを呼び出すことができません。 Uncaught exception 'SmartyException' with message 'Unable to load template db 'test.tpl'' in /usr/local/lib/php/smarty/sysplugins/smarty_internal_template.php:165 Stack trace: #0 /usr/local/lib/php/smarty/sysplugins/smarty_internal_template.php(554): Smarty_Internal_Template->isExisting(true) #1 /usr/local/lib/php/smarty/Smarty.class.php(340): Smarty_Internal_Template->getRenderedTemplate() #2 /usr/local/lib/php/smarty/Smarty.class.php(384): Smarty->fetch('test.tpl', NULL, NULL, NULL, true) #3 /usr/local/apache2/htdocs/test.php(18): Smarty->display('test.tpl') #4 {main} thrown in /usr/local/lib/php/smarty/sysplugins/smarty_internal_template.php on line 165 同様のプログラムでSmarty2*で実行するとうまく表示します。 Smarty3のマニュアル(英語版)を見てもうまくいきません。。 ご存知の方、ぜひ教えてください。 (環境) OS:Debian 6.0.1 WebServer:Apache2.2.19 PHP:PHP5.3.6 MySQL:MySQL5.0.87 (プラグイン) <?php require('DB.php'); define("DB_FILE","mysqli://*****:*****@localhost/*****"); function smarty_resource_db_source ($name, &$source, $o_smarty) { $db = DB::connect(DB_FILE); $stt = $db->prepare("SELECT source FROM templates WHERE name =?"); $rs = $db->execute($stt,array($name)); if(is_null($row=$rs->fetchRow(DB_FETCHMODE_ASSOC))){ return FALSE; }else{ $source=$row["source"]; return TRUE; } } function smarty_resource_db_timestamp($name, &$modified, $o_smarty) { $db = DB::connect(DB_FILE); $stt = $db->prepare("SELECT * FROM templates WHERE name =?"); $rs = $db->execute($stt,array($name)); if(is_null($row=$rs->fetchRow(DB_FETCHMODE_ASSOC))){ return FALSE; }else{ $modified=$row["modified"]; return TRUE; } } function smarty_resource_db_secure($name, $o_smarty) { // 全てのテンプレートがセキュアであると仮定します return true; } function smarty_resource_db_trusted($name, $o_smarty) { // テンプレートから使用しません } ?> (呼び出しファイル) <?php set_include_path('/usr/local/lib/php/smarty/:' . get_include_path()); @include('Smarty.class.php'); $o_smarty = new Smarty(); // Smartyのテンプレートのキャッシュファイル格納先を指定 $o_smarty->compile_dir = "/usr/local/apache2/htdocs/template_c"; $o_smarty->plugins_dir[]="/usr/local/apache2/htdocs/plugin"; $o_smarty->default_resource_type="db"; // phpスクリプトからテンプレートリソースを使用します $o_smarty->display("test.tpl"); ?> (データベース) CREATE TABLE templates ( name VARCHAR(100) NOT NULL default '', modified TIMESTAMP, source TEXT, PRIMARY KEY (name) ) DEFAULT CHARACTER SET utf8; -- Dumping data for table 'templates' INSERT INTO templates VALUES('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');

    • 締切済み
    • PHP
  • Smartyについて

    Smartyについて Smartyをインストールしました。 OS:ubuntu インストール先:/usr/local/lib/Smarty-2.6.26 php.ini[include_path]の設定:/usr/local/lib/Smarty-2.6.26/libs/を追加 /var/www/以下にtestフォルダ作成 /var/www/test/index.html | /test/index.php chmod 644 | /tempalates chmod 775 templates | / index.tpl chmod 644 /templates_c chmod 775 templates_c /configs chmod 775 configs /cache chmod 775 cache index.phpの内容 <?php require_once(”Smarty.class.php"); $o_smarty=new Smarty(); $o_smarty->template_dir="./templates/"; $o_smarty->compile_dir="./template_c/"; $o_smarty->assign("name","world"); $o_smarty->display("hello.tpl"); ?> index.tplの内容 <html> <head> <title>Hello,world</title> </head> <body> Hello,{$name}! </body> </html> http://web.domain/test/index.php を入力するとエラーは出ませんが、何も表示されません。 これだけで、原因を特定出来ないのかもしれませんが、何処が悪いのでしょうか? 御教示お願いいたします。

  • php クラス

    phpエクラスの勉強をしているのですが、参考書に書いているメンバ変数に値を代入している意味がよくわからないので教えてください。メンバ変数の値を書かなくtも動作できるのになぜ必要なのでしょうか? 参考書 <html> <head> <title>サンプル</title> </head> <body> <?php $pr = new Person; $pr->name = "鈴木"; $pr->age = 56; ?> <table border="2"> <tr bgcolor="#AAAAAA"> <th>名前</th> <th>年齢</th> </tr> <?php print "<tr><td>"; print $pr->getname(); print "</td><td>"; print $pr->getage(); print "</td></tr>"; ?> </table> <?php class Person { public $name ="姓名"; public $age = 20; function getname(){return $this->name;} function getage(){return $this->age;} } ?> </body> </html> テスト <?php class Person { public $name ;←ここに値を格納する意味 public $age ;←ここに値を格納する意味 function getname(){return $this->name;} function getage(){return $this->age;} } ?>

    • ベストアンサー
    • PHP
  • smartyについて

    phpからassignしテンプレートに表示するには問題ないのですがテンプレートでassignし 表示させたく単純に以下のようにしてみましたがエラーになってしまいます。 <{assign var="aaa"value="名前"}> <{$aaa}> ※デリミタ設定は『<{』と『}>』で指定してます エラー内容は以下の通りです。 Fatal error: Smarty error: [in テンプレートファイル line assignしている行]: syntax error: invalid attribute name: '=' (Smarty_Compiler.class.php, line 1550) in ~中略~\Smarty\Smarty.class.php on line 1093 なんとなくではありますが'='が原因のような事はわかるのですが解決できずにおります。 この場合どうすればいいのでしょうか?

    • ベストアンサー
    • PHP

専門家に質問してみよう