tft每日頭條

 > 科技

 > php 變量為空不執行查詢

php 變量為空不執行查詢

科技 更新时间:2025-08-18 21:25:15

php 變量為空不執行查詢(php判斷文件目錄函數)1

判斷文件和目錄

文件是否存在:file_exists;

目錄是否存在:is_dir;

例子:

$dir='./data';

if(is_dir($dir)) echo "目錄".$dir."存在"; else echo "目錄".$dir."不存在";

類,類方法,普通方法函數

類是否存在:class_exists('calss');

類裡面的某個方法是否存在:method_exists ($class,'method');

系統函數或自己寫的函數是否存在:function_exists('function');

例子:

class main{

function index(){

echo '我是類裡的index方法';

}

}

function index(){

echo '我是index方法';

}

if(class_exists('main')) $main=new main();

if(method_exists($main,'index')) $main->index();//我是類裡的index方法

if(function_exists('index')) index(); else echo '沒有index方法'; //我是index方法

變量

變量是否存在:isset() 、empty()與is_null

isset()在變量不存在或者為null時,判斷為false;

empty()在變量不存在和$x=''/null/array()/false/0/'0',判斷為true

is_null()與isset相反

php 變量為空不執行查詢(php判斷文件目錄函數)2


,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2025 - www.tftnews.com All Rights Reserved