Contents [hide]
输出结果
value is not defined
程式码
JavaScript
1 2 3 4 5 | if ( typeof value !== 'undefined' ) { console.log( 'value is defined' ); } else { console.log( 'value is not defined' ); } |
PHP
1 2 3 4 5 6 7 | <?php if (isset( $value )) { print "value is defined\n" ; } else { print "value is not defined\n" ; } |
Perl
1 2 3 4 5 6 | if ( defined ( $value )) { print "value is defined\n" ; } else { print "value is not defined\n" ; } |
Python
1 2 3 4 5 6 | try : value except NameError: print ( "value is not defined" ) else : print ( "value is defined" ) |
Ruby
1 2 3 4 5 | if defined ? value puts "value is defined" else puts "value is not defined" end |

作者: 栗田 創。1st Class, inc的首席执行官/首席技术官。搜索引擎工程师、网站管理员
证书: AWS Solution Architect,Professional Scrum Master I ,一级IT工程师(日本国家证书),TOEIC900+,东京大学経済学部経営学科卒业
请关注我的Weblio帐户以获取更新
IT相关服务:VPS排名