var-dump

Alternative var_dump for PHP that allows limiting depth of nested arrays

…衆ロ難τιáo~ 提交于 2019-12-23 07:52:51
问题 I try to use var_dump on command line with phpsh in order to get debugging information about some variable. But the variable contains a very deeply nested data structure. Therefore, using the default var_dump outputs too much information. I want to limit the depth level of var_dump output. I found that XDebug's var_dump implementation allows depth limiting as described here: http://www.giorgiosironi.com/2009/07/how-to-stop-getting-megabytes-of-text.html Unfortunately, I couldn't make this

Debug php with Netbeans - Newbie source request

拟墨画扇 提交于 2019-12-23 02:52:11
问题 I'm using var_dump. Everywhere. It's a mess. And slow. I would like to lock a variable, right-click, choose test, and it will show me the output results on each period or my script, on a IDE window. - 1) Does something like this exist on Netbeans ? 2) Regardless about what could the "best" thing here, am wondering, if anyone could advice me some books/resources on the subject: "Debugging for newbies" ? Update: I realise that netbeans does have some possible integration. The hard part, however

Convert var_dump of array back to array variable

[亡魂溺海] 提交于 2019-12-13 14:22:44
问题 I have never really thought about this until today, but after searching the web I didn't really find anything. Maybe I wasn't wording it right in the search. Given an array (of multiple dimensions or not): $data = array('this' => array('is' => 'the'), 'challenge' => array('for' => array('you'))); When var_dumped: array(2) { ["this"]=> array(1) { ["is"]=> string(3) "the" } ["challenge"]=> array(1) { ["for"]=> array(1) { [0]=> string(3) "you" } } } The challenge is this: What is the best

PHP Empty string of length 32

China☆狼群 提交于 2019-12-13 14:08:34
问题 EDIT: The string was being outputted and interpreted by the browser. Silly mistake. In my project, I have created a class to generate the HTML tags I need, rather echo them all out myself. I have a function called generateTag($control, $isCardValue = true) in a php class called Card . This function generates an HTML tag based on the properties passed through the array parameter $control . Here is what the function looks like: public function generateTag($control, $isCardValue = true) { if (

var_dump outputting string('**') “array”

馋奶兔 提交于 2019-12-13 08:29:49
问题 I am using a foreach loop and a var_dump but the var_dump from the following code outputs something strange. How do I get rid of the pre-prended sring() and quotation marks? $dir = 'url/dir/dir/'; $images_array = glob($dir.'*.jpg'); $images = array(); foreach ($images_array as $image) { $images[] = str_replace($dir, '', $image); } var_dump(implode(',', $images)); Output: string(51) "image1.jpg,image2.jpg,image3.jpg,image4.jpg" 回答1: That's what var_dump does - it prints the datatype and the

PHP var_dump and loop giving different results

假如想象 提交于 2019-12-13 05:26:48
问题 I have the following code: var_dump($cursor); foreach($cursor as $obj) { echo "<div class='item' id='" . $obj['_id'] . "'>"; echo "<span class='listnick'>" . $obj['nick'] . "</span>"; echo "</div>"; } The result of var_dump is the following: array(2) { [0]=> &array(9) { ["_id"]=> object(MongoId)#9 (1) { ["$id"]=> string(24) "50af8dcd9cc231534400000c" } ["nick"]=> string(6) "safari" } [1]=> array(9) { ["_id"]=> object(MongoId)#8 (1) { ["$id"]=> string(24) "50af8dca9cc2315644000009" } ["nick"]=

How to get instance ID with PHP

ε祈祈猫儿з 提交于 2019-12-12 11:35:37
问题 I'm looking for a way to get the instance ID of a given object / resource with PHP, the same way var_dump() does: var_dump(curl_init()); // resource #1 of type curl var_dump(curl_init()); // resource #2 of type curl How can I get the instance count without calling var_dump()? Is it possible? 回答1: Convert it to an int to get the resource ID: $resource= curl_init(); var_dump($resource); var_dump(intval($resource)); 回答2: (int) curl_init() 回答3: This is a very interesting question... I would be

When I debug php with var_dump variable it always outputs file path at the beginning?

泄露秘密 提交于 2019-12-10 16:50:39
问题 I am using Ubuntu with PHP 7. PHP 7.0.5-3+donate.sury.org~xenial+1 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans When I debug a PHP script by using var_dump to show some variable: <?php var_dump('tmp string'); var_dump(true); The below is its output: /var/www/example.com/test.php:3:string

PHP session index undefined after header redirection?

拥有回忆 提交于 2019-12-10 13:30:01
问题 I have struggled with this for hours but I can't get it to work. When I do a redirection to another PHP page, all my session variables are null. I am on xampp server. session.php <?php session_start(); if(isset($_POST['submitted'])) { $_SESSION['first_name'] = "MAX"; var_dump($_SESSION); header("Location: http://localhost:8080/secure login/session2.php"); die(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http

xdebug var_dump function colors

折月煮酒 提交于 2019-12-10 07:30:21
问题 I have installed xdebug on my computer with windows and it works fine by default - traces are colorfull and pretty but on another computer with ubuntu 10.10 its colourless and without any formatting. I tryed fill xdebug formatting parameters in php.ini but it didn't work for me :( What I need to make for improving output formatting? 回答1: I faced this problem once upon a time and turned out to be : open php.ini and look for html_errors in your case it should be off , so simply turn it on and