私はstackoverflowや他のサイトを検索し、数時間前から新しいコードの組み合わせを試しましたが、私はあきらめます。 私は2つのPHPファイル、1つはgetimages.phpと呼ばれ、もう1つはmod_slidepluslight.phpと呼ばれます。私はCMSとしてJoomlaを使用していてライトボックスでスライドショーモジュールを作成しましたが、.xmlファイルで設定されたモジュールパラメータを使ってJoomla内のフォルダから画像を取得します。私はこの変数を宣言すると、それは何もしない私のコードでそれを使用しようとすると、今function()内の他のPHPスクリプトからphp変数を使用する方法
$imagePath = $params->get('imagePath', 'banners');
:私はこのコードを使用することによってこれをしませんでした。
function returnimages($relPath = "/KVD/images/") {
$dirname = $_SERVER['DOCUMENT_ROOT'] . $relPath . $imagePath;
$画像パスは、/KVD/images/......./の後に追加するか、現在の場所に追加する必要があります。
Header("content-type: application/x-javascript");
$imagePath = $params->get('imagePath', 'banners/');
function returnimages($relPath = "/KVD/images/") {
$dirname = $_SERVER['DOCUMENT_ROOT'] . $relPath . $imagePath;
$files = array();
$curimage = 0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if (preg_match('/\.(jpg|jpeg|gif|png)$/', $file)){
print_r ('galleryarray['.$curimage.']="'. $relPath . $file .'";');
$curimage++;
}
}
closedir($handle);
}
return($files);
}
print 'var galleryarray=new Array();'; //Define array in JavaScript
returnimages() //Output the array elements containing the image file names
おかげで、公園:getimages.phpの全体のコードは次のようになります。
答えをいただきありがとうございます。自分の関数内に$ imagePath = ....を追加する必要がありますか? – Koen
これは可能な解決策です。関数returnimages($ relPath = "/ KVD/images /"、$ imagePath)を呼び出すと、returnimages(null、$ imagePath)を返します。 –
チャットであなたを招待できますか? – Koen