isset

Check if an array item is set in JS

强颜欢笑 提交于 2019-12-03 06:40:33
问题 I've got an array var assoc_pagine = new Array(); assoc_pagine["home"]=0; assoc_pagine["about"]=1; assoc_pagine["work"]=2; I tried if (assoc_pagine[var] != "undefined") { but it doesn't seem to work I'm using jquery, I don't know if it can help Thanks 回答1: Use the in keyword to test if a attribute is defined in a object if (assoc_var in assoc_pagine) OR if ("home" in assoc_pagine) There are quite a few issues here. Firstly, is var supposed to a variable has the value "home", "work" or "about"

Check if variable is_undefined in PHP

百般思念 提交于 2019-12-03 06:01:01
In PHP, I want to check if a variable has not been set/defined, where setting a variable NULL is considered set/defined . I'm aware everything here: http://php.net/manual/en/types.comparisons.php including isset(), empty(), and is_null(). None of these appear to be what I'm looking for. Consider the following example: <?php $myNull = null; echo 'isset($myNull): "'.isset($myNull).'"<br />'; echo '$myNull value = "'.$myNull . '"<br />'; echo "<br />"; echo 'isset($myUndefined): "'.isset($myUndefined).'"<br />'; echo '$myUndefined value = "'.$myUndefined . '"<br />'; ?> This example outputs

function http_build_url()

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I work with windows 7 using WampServer Version 2.2 php5.3.13 I put my project in www and during the execution of my project this error is displayed Fatal error: Call to undefined function http_build_url() in C:\wamp\www in the source code of my project I use this syntax $url = http_build_url($url); I think I need to configure wamp 回答1: Check your extensions folder for php_http.dll file. If the file is present, check that php_http extension is enabled in your php.ini (or any other included .ini-s) If the file is absent, either download it

php recursive merge

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to merge some arrays in some different way and I use array_merge_recursive. However there is something that I need to change and I don't know how. Here is quote from php.net If, however, the arrays have the same numeric key, the later value will not overwrite the original value, but will be appended. I want this value, NOT to be appended, I want not to append exact values in the new array.Hope you've understood this. Example: $array = array( 'some' => array( 'other' => 'key', ), ); $array2 = array(); $array2['some']['other'] = 'key2';

undefined index text fields php database?

匿名 (未验证) 提交于 2019-12-03 02:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: when i enter the url(//login.php) after login it gives undefined index on t1 and t2. how can i use session on this page index.php <head> <link rel="stylesheet" type="text/css" href="css/style.css"></head> <h1>Login Here</h1> <form name="f1" action="login.php" method="post"> <table border="1"> <tr><td>username</td><td><input type="text" name="t1"></td> </tr> <tr><td>password</td><td><input type="password" name="t2"></td></tr> <tr><td><input type="submit" value="login"></td> <td class="error"><?php if(isset($_GET['wrong_detial'])){ echo "RE

Weird PHP error: 'Can't use function return value in write context'

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm getting this error and I can't make head or tail of it. The exact error message is: Fatal error: Can't use function return value in write context in /home/curricle/public_html/descarga/index.php on line 48 Line 48 is: if ( isset ( $_POST ( 'sms_code' ) == TRUE ) { Anybody knows what's going on??? PS Here's the full function, in case it helps: function validate_sms_code () { $state = NOTHING_SUBMITED ; if ( isset ( $_POST ( 'sms_code' ) == TRUE ) { $sms_code = clean_up ( $_POST ( 'sms_code' )); $return_code = get_sepomo_code (

isset() and empty() - what to use [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: Why check both isset() and !empty() Could you help me to improve my coding style?:) In some tasks I need to check - is variable empty or contains something. To solve this task, I usually do the following. Check - is this variable set or not? If it's set - I check - it's empty or not? And I have a question - should I use isset() before empty() - is it necessary? TIA! 回答1: It depends what you are looking for, if you are just looking to see if it is empty just use empty as it checks whether it is set as well, if you want to

“Illegal offset type in isset or empty” when using a Twig macro

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Using Grav v1.3.8 (running on PHP 5.6.30), I'm currently getting a Server error ( "Illegal offset type in isset or empty" ) when trying to render a Twig template that is using a macro. What's interesting is that this only happens when I use the macro by itself. As soon as I append a filter, like trim , everything works as expected. The (shortened) macro file, helpers.twig : The template (MCVE): {% import 'macros/helpers.twig' as helpers %} {% set img = helpers.ascii('günter-berger.jpg') %} {% if page.media[img] is defined %} <img src="{{

How to validate a checkbox input using PHP?

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two check boxes in my form: <div class="label-input-wrapper pickup"> <div class="form-label">I need Airport pick-up</div> <div class="form-input"> <input type="checkbox" name="pick_up" value="Yes" />Yes <input type="checkbox" name="pick_up" value="No" />No <div class="error-msg"> <?php if(isset($errors['pick_up_no'])) { echo '<span style="color: red">'.$errors['pick_up_no'].'</span>'; } ?> </div> </div> </div> Variable that saves the value of the above check boxes: $pickup = $_POST['pick_up']; Validation: //Check the airport pickup

Compile Error: Cannot use isset() on the result of an expression

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm getting this error in a app I am migrating from SF2.0.x to SF2.7: [ 1 ] Symfony \Component\Debug\Exception\FatalErrorException : Compile Error : Cannot use isset () on the result of an expression ( you can use "null !== expression" instead ) at n / a in / var / www / html / reptooln_admin / app / cache / dev / twig / 68 / 7f / 63589dd3687cb849dd68e6b6c10aa99eda1d82f95a5f3ac52a864d200499.php line 39 I don't know what is failing or how to fix this so I need some advise. This is the line at cache file where the Stacktrace is