php每天学习一点点-第三天

Posted Re

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php每天学习一点点-第三天相关的知识,希望对你有一定的参考价值。

get_defined_vars 获取所有已经定义的变量,并将他们放入到数组内


<?php
$bd1 = "我是变量bd1";
$bd2 = "我是变量db2";
$bd3 = "我是变量db3";
//获取所有已经定义的变量并放入到data变量内
$data =get_defined_vars();
//输出
var_dump($data);
/*
 *
 *  array (size=11)
  ‘_GET‘ =>
    array (size=0)
      empty
      ‘_POST‘ =>
    array (size=0)
      empty
      ‘_COOKIE‘ =>
    array (size=0)
      empty
      ‘_FILES‘ =>
    array (size=0)
      empty
      ‘_SERVER‘ =>
    array (size=37)
      ‘PATH‘ => string ‘C:Program Files (x86)Common FilesOracleJavajavapath;D:pyScripts;D:py;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;D:BtSoftpanelscript;D:
ode;D:BtSoftphp73;D:BtSoftphp;D:goin;D:Gitcmd;C:Program Filesdotnet;C:Program FilesMicrosoft SQL Server130ToolsBinn;C:Program FilesMicrosoft SQL ServerClient SDKODBC170ToolsBinn;;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:Program Files (x‘... (length=653)
      ‘SYSTEMROOT‘ => string ‘C:Windows‘ (length=10)
      ‘COMSPEC‘ => string ‘C:Windowssystem32cmd.exe‘ (length=27)
      ‘PATHEXT‘ => string ‘.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW‘ (length=62)
      ‘WINDIR‘ => string ‘C:Windows‘ (length=10)
      ‘_FCGI_SHUTDOWN_EVENT_‘ => string ‘2324‘ (length=4)
      ‘SCRIPT_NAME‘ => string ‘/index.php‘ (length=10)
      ‘REQUEST_URI‘ => string ‘/‘ (length=1)
      ‘QUERY_STRING‘ => string ‘‘ (length=0)
      ‘REQUEST_METHOD‘ => string ‘GET‘ (length=3)
      ‘SERVER_PROTOCOL‘ => string ‘HTTP/1.1‘ (length=8)
      ‘GATEWAY_INTERFACE‘ => string ‘CGI/1.1‘ (length=7)
      ‘REMOTE_PORT‘ => string ‘56629‘ (length=5)
      ‘SCRIPT_FILENAME‘ => string ‘D:/wwwroot/vueadmin/index.php‘ (length=29)
      ‘SERVER_ADMIN‘ => string ‘webmaster@example.com‘ (length=21)
      ‘CONTEXT_DOCUMENT_ROOT‘ => string ‘D:/wwwroot/vueadmin/‘ (length=20)
      ‘CONTEXT_PREFIX‘ => string ‘‘ (length=0)
      ‘REQUEST_SCHEME‘ => string ‘http‘ (length=4)
      ‘DOCUMENT_ROOT‘ => string ‘D:/wwwroot/vueadmin/‘ (length=20)
      ‘REMOTE_ADDR‘ => string ‘127.0.0.1‘ (length=9)
      ‘SERVER_PORT‘ => string ‘80‘ (length=2)
      ‘SERVER_ADDR‘ => string ‘127.0.0.1‘ (length=9)
      ‘SERVER_NAME‘ => string ‘vueadmin.cn‘ (length=11)
      ‘SERVER_SOFTWARE‘ => string ‘Apache/2.4.41 (Win32) OpenSSL/1.1.1c mod_fcgid/2.3.9a‘ (length=53)
      ‘SERVER_SIGNATURE‘ => string ‘‘ (length=0)
      ‘SystemRoot‘ => string ‘C:Windows‘ (length=10)
      ‘HTTP_ACCEPT_LANGUAGE‘ => string ‘zh-CN,zh;q=0.9‘ (length=14)
      ‘HTTP_ACCEPT_ENCODING‘ => string ‘gzip, deflate‘ (length=13)
//      ‘HTTP_ACCEPT‘ => string ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9‘ (length=124)
//      ‘HTTP_USER_AGENT‘ => string ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36‘ (length=110)
//      ‘HTTP_UPGRADE_INSECURE_REQUESTS‘ => string ‘1‘ (length=1)
//      ‘HTTP_CONNECTION‘ => string ‘close‘ (length=5)
//      ‘HTTP_HOST‘ => string ‘vueadmin.cn‘ (length=11)
//      ‘FCGI_ROLE‘ => string ‘RESPONDER‘ (length=9)
//      ‘PHP_SELF‘ => string ‘/index.php‘ (length=10)
//      ‘REQUEST_TIME_FLOAT‘ => float 1587823518.637
//      ‘REQUEST_TIME‘ => int 1587823518
//  ‘_REQUEST‘ =>
//    array (size=0)
//      empty
//      ‘_ENV‘ =>
//    array (size=0)
//      empty
//      ‘GLOBALS‘ =>
//    array (size=12)
//      ‘_GET‘ =>
//        array (size=0)
//          empty
//          ‘_POST‘ =>
//        array (size=0)
//          empty
//          ‘_COOKIE‘ =>
//        array (size=0)
//          empty
//          ‘_FILES‘ =>
//        array (size=0)
//          empty
//          ‘_SERVER‘ =>
//        array (size=37)
//          ‘PATH‘ => string ‘C:Program Files (x86)Common FilesOracleJavajavapath;D:pyScripts;D:py;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;D:BtSoftpanelscript;D:
ode;D:BtSoftphp73;D:BtSoftphp;D:goin;D:Gitcmd;C:Program Filesdotnet;C:Program FilesMicrosoft SQL Server130ToolsBinn;C:Program FilesMicrosoft SQL ServerClient SDKODBC170ToolsBinn;;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:Program Files (x‘... (length=653)
//          ‘SYSTEMROOT‘ => string ‘C:Windows‘ (length=10)
//          ‘COMSPEC‘ => string ‘C:Windowssystem32cmd.exe‘ (length=27)
//          ‘PATHEXT‘ => string ‘.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW‘ (length=62)
//          ‘WINDIR‘ => string ‘C:Windows‘ (length=10)
//          ‘_FCGI_SHUTDOWN_EVENT_‘ => string ‘2324‘ (length=4)
//          ‘SCRIPT_NAME‘ => string ‘/index.php‘ (length=10)
//          ‘REQUEST_URI‘ => string ‘/‘ (length=1)
//          ‘QUERY_STRING‘ => string ‘‘ (length=0)
//          ‘REQUEST_METHOD‘ => string ‘GET‘ (length=3)
//          ‘SERVER_PROTOCOL‘ => string ‘HTTP/1.1‘ (length=8)
//          ‘GATEWAY_INTERFACE‘ => string ‘CGI/1.1‘ (length=7)
//          ‘REMOTE_PORT‘ => string ‘56629‘ (length=5)
//          ‘SCRIPT_FILENAME‘ => string ‘D:/wwwroot/vueadmin/index.php‘ (length=29)
//          ‘SERVER_ADMIN‘ => string ‘webmaster@example.com‘ (length=21)
//          ‘CONTEXT_DOCUMENT_ROOT‘ => string ‘D:/wwwroot/vueadmin/‘ (length=20)
//          ‘CONTEXT_PREFIX‘ => string ‘‘ (length=0)
//          ‘REQUEST_SCHEME‘ => string ‘http‘ (length=4)
//          ‘DOCUMENT_ROOT‘ => string ‘D:/wwwroot/vueadmin/‘ (length=20)
//          ‘REMOTE_ADDR‘ => string ‘127.0.0.1‘ (length=9)
//          ‘SERVER_PORT‘ => string ‘80‘ (length=2)
//          ‘SERVER_ADDR‘ => string ‘127.0.0.1‘ (length=9)
//          ‘SERVER_NAME‘ => string ‘vueadmin.cn‘ (length=11)
//          ‘SERVER_SOFTWARE‘ => string ‘Apache/2.4.41 (Win32) OpenSSL/1.1.1c mod_fcgid/2.3.9a‘ (length=53)
//          ‘SERVER_SIGNATURE‘ => string ‘‘ (length=0)
//          ‘SystemRoot‘ => string ‘C:Windows‘ (length=10)
//          ‘HTTP_ACCEPT_LANGUAGE‘ => string ‘zh-CN,zh;q=0.9‘ (length=14)
//          ‘HTTP_ACCEPT_ENCODING‘ => string ‘gzip, deflate‘ (length=13)
//          ‘HTTP_ACCEPT‘ => string ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9‘ (length=124)
//          ‘HTTP_USER_AGENT‘ => string ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36‘ (length=110)
//          ‘HTTP_UPGRADE_INSECURE_REQUESTS‘ => string ‘1‘ (length=1)
//          ‘HTTP_CONNECTION‘ => string ‘close‘ (length=5)
//          ‘HTTP_HOST‘ => string ‘vueadmin.cn‘ (length=11)
//          ‘FCGI_ROLE‘ => string ‘RESPONDER‘ (length=9)
//          ‘PHP_SELF‘ => string ‘/index.php‘ (length=10)
//          ‘REQUEST_TIME_FLOAT‘ => float 1587823518.637
//          ‘REQUEST_TIME‘ => int 1587823518
//      ‘_REQUEST‘ =>
//        array (size=0)
//          empty
//          ‘_ENV‘ =>
//        array (size=0)
//          empty
//          ‘GLOBALS‘ =>
//        &array<      ‘bd1‘ => string ‘我是变量bd1‘ (length=15)
//      ‘bd2‘ => string ‘我是变量db2‘ (length=15)
//      ‘bd3‘ => string ‘我是变量db3‘ (length=15)
//      ‘data‘ =>
//        &array<  ‘bd1‘ => string ‘我是变量bd1‘ (length=15)
//  ‘bd2‘ => string ‘我是变量db2‘ (length=15)
//  ‘bd3‘ => string ‘我是变量db3‘ (length=15)*/

get_resource_type 返回资源类型


<?php
$type = get_resource_type(fopen("flag.php",‘r‘));
var_dump($type);
/**
 *string ‘stream‘ (length=6)
 */

gettype 获取变量类型


<?php
$type = 1;
$type1 = ‘1‘;
$type2 = 1.01;
var_dump(gettype($type),gettype($type1),gettype($type2));
/**
 * D:wwwrootvueadminindex.php:5:string ‘integer‘ (length=7)
D:wwwrootvueadminindex.php:5:string ‘string‘ (length=6)
D:wwwrootvueadminindex.php:5:string ‘double‘ (length=6)
 */

以上是关于php每天学习一点点-第三天的主要内容,如果未能解决你的问题,请参考以下文章

php课程的第三天

Magento学习手记(第三天)

Web-第三十三天 MongoDB初级学习

学习PHP课程的第三天

学习PHP课程的第三天

PHP微信商城学习日记----第三天