Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 1.11 KB

GlobalApi.md

File metadata and controls

89 lines (63 loc) · 1.11 KB

Global Api

parseInt

const a = parseInt('1.2');
$a = intval("1.2");

parseFloat

const b = parseFloat('1.2');
$b = floatval("1.2");

typeof

由于 php 中没有 undefined 关键字,故不支持返回 undefined,如果你写了,会被转成 null

There is no undefined in PHP. It will be transformed to null if you use it.

const a = parseInt('1.2');
const c = typeof a;
const d = typeof c === 'string';
$a = intval("1.2");
$c = \Ts2Php_Helper::typeof($a);
$d = \Ts2Php_Helper::typeof($c) === "string";

delete

const e = {a: 1, b: 2};
delete e.a;
$e = array( "a" => 1, "b" => 2 );
unset($e["a"]);

navigator.userAgent

const f = navigator.userAgent;
$f = $_SERVER["HTTP_USER_AGENT"];

__dirname/__filename

const g = __dirname;
const h = __filename;
$g = dirname(__FILE__);
$h = __FILE__;

escape

import {escape} from './helper/export';

escape();
require_once(dirname(__FILE__) . '/' . "./helper/export.php");
\someModule\escape();