isset

PHP isset($this) and using the same object method in a static and object context

我是研究僧i 提交于 2019-12-05 11:10:39
I'm working on a class which needs to be accessible via static function calls as well as object methods. One thing I have found is that I'm duplicating logic across multiple functions. Simplified example: class Configurable{ protected $configurations = array(); protected static $static_configurations = array(); public function configure($name, $value){ // ...lots of validation logic... $this->configurations[$name] = $value; } public static function static_configure($name, $value){ // ...lots of validation logic (repeated)... self::$static_configurations[$name] = $value; } } I've found a

How to tell whether a variable in ASP has been declared

此生再无相见时 提交于 2019-12-05 06:54:34
Let me start off by saying I'm a PHP developer, not an ASP one. (And I really wish ASP had isset() .) And I'm working in a live environment so I don't really have an opportunity to do any testing. All the resources I've found suggest different ways to test for the existence of a variable. Here's what I'm trying to do: On SOME pages, I set a variable which holds a value for a robots <meta> tag: dim dsep_robots dsep_robots = "nofollow,noindex" All pages include header.asp . In my header file, I want to test whether dsep_robots has a value and if so, output that value, otherwise, output nothing.

Is there a shortcut for the “isset construct”?

断了今生、忘了曾经 提交于 2019-12-05 02:09:39
I'm writing quite often this line of code: $myParam = isset($params['myParam']) ? $params['myParam'] : 'defaultValue'; Typically, it makes the line very long for nested arrays. Can I make it shorter? function getOr(&$var, $default) { if (isset($var)) { return $var; } else { return $default; } } $myParam = getOr($params['myParam'], 'defaultValue'); Be sure to pass the variable by reference though, otherwise the code will produce a E_NOTICE. Also the use of if/else instead of a ternary operator is intentional here, so the zval can be shared if you are using PHP < 5.4.0RC1. Yes, by making a proxy

CTF Web题

我与影子孤独终老i 提交于 2019-12-04 16:36:26
1.web2 听说聪明的人都能找到答案 http://123.206.87.240:8002/web2/ CTRL + u 查看源代码 2.计算器 http://123.206.87.240:8002/yanzhengma/ 改一下字符输入长度的限制 3.web基础$_GET http://123.206.87.240:8002/get/ ?var=val 4.web基础$_POST http://123.206.87.240:8002/get/index1.php 直接用BurpSuite改包,注意先改为POST request 5.矛盾 http://123.206.87.240:8002/get/index1.php $num = GET[′num′];if(!isnumeric( G​ET[′num′];if(!isn​umeric(num)) { echo num;if( num;if(num == 1) echo ‘flag{**********}’; } 此处 == 为弱类型判断,num = 1e ,num == 1 6.web3 flag就在这里快来找找吧 http://123.206.87.240:8002/web3/ 直接查看源码,得KEY{J2sa42a hJK-HS11III} 扔到 Burp 解码试试,解为html得flag 7.域名解析 听说把 flag

PHP之十六个魔术方法详细介绍

此生再无相见时 提交于 2019-12-04 14:05:18
PHP中把以两个下划线__开头的方法称为魔术方法(Magic methods),这些方法在PHP中充当了举足轻重的作用。 魔术方法包括: __construct(),类的构造函数 __destruct(),类的析构函数 __call(),在对象中调用一个不可访问方法时调用 __callStatic(),用静态方式中调用一个不可访问方法时调用 __get(),获得一个类的成员变量时调用 __set(),设置一个类的成员变量时调用 __isset(),当对不可访问属性调用isset()或empty()时调用 __unset(),当对不可访问属性调用unset()时被调用。 __sleep(),执行serialize()时,先会调用这个函数 __wakeup(),执行unserialize()时,先会调用这个函数 __toString(),类被当成字符串时的回应方法 __invoke(),调用函数的方式调用一个对象时的回应方法 __set_state(),调用var_export()导出类时,此静态方法会被调用。 __clone(),当对象复制完成时调用 __autoload(),尝试加载未定义的类 __debugInfo(),打印所需调试信息 范例 下面让我们以实例的形式向大家讲解下这几个魔术方法时如何使用的。 一、 __construct(),类的构造函数

What does the exclamation point mean in PHP? [duplicate]

走远了吗. 提交于 2019-12-04 13:54:19
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Reference - What does this symbol mean in PHP? Getting confused with empty, isset, !empty, !isset In PHP what is the difference between: if(!isset) if(isset) Same with if(!empty) and if(empty) ? What does the "!" character mean? 回答1: ! is the logical negation or NOT operator. It reverses the sense of the logical test. That is: if(isset) makes something happen if isset is logical True . if(!isset) makes something

PHP判断是否为手机端的方法

若如初见. 提交于 2019-12-04 10:54:06
PHP判断是否为手机端的方法 private function ismobile() { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) { return true; } //此条摘自TPM智能切换模板引擎,适合TPM开发 if (isset($_SERVER['HTTP_CLIENT']) && 'PhoneClient' == $_SERVER['HTTP_CLIENT']) { return true; } //如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 if (isset($_SERVER['HTTP_VIA'])) //找不到为flase,否则为true { return stristr($_SERVER['HTTP_VIA'], 'wap') ? true : false; } //判断手机发送的客户端标志,兼容性有待提高 if (isset($_SERVER['HTTP_USER_AGENT'])) { $clientkeywords = array( 'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips',

Check if a property exists on magically set properties

筅森魡賤 提交于 2019-12-04 10:26:07
问题 There is a lot of SO questions about the subject, notably this one, but it does not help me. There is an ambiguity between property_exists and isset so before asking my question, I'm going to pointing it out: property_exists property_exists checks if an object contains a property without looking at its value, it only looks at its visibility. So in the following example: <?php class testA { private $a = null; } class testB extends testA { } $test = new testA(); echo var_dump(property_exists(

isset value always returns 1

自古美人都是妖i 提交于 2019-12-04 06:29:25
问题 I am a newbie when it comes to PHP. I am trying to make a login and logout webpage. Now, I have created a page which would add records. MY code always returns 1 from the form that i built, irrespective of the value in the form. My code- <?php $servername = "localhost"; $username = "username"; $password = "password"; $alpha = isset($_GET["username"]); $beta = isset($_GET["password"]); $gama = isset($_GET["hobby"]); // Create connection $conn = mysqli_connect("localhost","root" ,"","member"); /

PHP - proper check if $_POST['variable'] is posted

早过忘川 提交于 2019-12-04 04:40:30
问题 I want to check if $_POST['submit'] is posted. My original code was: if ($_POST['submit']) { } But I have a PHP notice with this code - "Undefined index: submit in..." So to remove the notice I have to write this: if (isset($_POST['submit'])) { } But this is pointless because $_POST array is global and it return always true. Also if I want to check if $_POST['submit'] is not 0 without PHP notice I have to write this: if (isset($_POST['submit']) && $_POST['submit'] != 0) { } In this particular