Print_r returns nothing; var_dump shows NULL

I am new to web design and I am experimenting with Braintree webcams. I use their example submerchant example example to create a submaster, and then supposedly the notification should reach my server, which says it was successful or not.

My method: I refresh the submerchant.php page (I use Wordpress on the NameCheap server), which then echo "Success!". Then go to webhooks.php and refresh it. However, var_dump returns only NULL NULL , and print_r returns nothing. Why is print_r not displaying anything?

submerchant.php - this creates a submaster when I set $one = 1 and set a new id for the submerchant

 <?php require_once(__DIR__ . '/../braintree/lib/Braintree.php'); Braintree_Configuration::environment('sandbox'); Braintree_Configuration::merchantId('A'); Braintree_Configuration::publicKey('B'); Braintree_Configuration::privateKey('C'); function fd_create_sm() { $one; $one = 1; if($one=1) { $merchantAccountParams = [ 'individual' => [ 'firstName' => 'Janez', 'lastName' => 'Doe', 'email' => ' jane@14ladders.com ', 'phone' => '5553334444', 'dateOfBirth' => '1981-11-19', 'ssn' => '456-45-4567', 'address' => [ 'streetAddress' => '111 Main St', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622' ] ], 'business' => [ 'legalName' => 'Jane\ Ladders', 'dbaName' => 'Jane\ Ladders', 'taxId' => '98-7654321', 'address' => [ 'streetAddress' => '111 Main St', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622' ] ], 'funding' => [ 'descriptor' => 'Red Ladders', 'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK, 'email' => ' funding@blueladders.com ', 'mobilePhone' => '5555555555', 'accountNumber' => '1123581321', 'routingNumber' => '071101307' ], 'tosAccepted' => true, 'masterMerchantAccountId' => "na", 'id' => "green_ladders" ]; $result = Braintree_MerchantAccount::create($merchantAccountParams); $result->success; if($result->success) { echo 'Success!'; } else { print_r($result->errors); $errordata; echo '***********'; $BT_Errors = new Braintree_Error_ErrorCollection($errordata); echo '***********'; $BT_Errors->deepAll(); echo '***********'; $BT_Errors->onHtmlField("transaction[amount]"); } $result->merchantAccount->status; $result->merchantAccount->id; // "blue_ladders_store" $result->merchantAccount->masterMerchantAccount->id; // "14ladders_marketplace" $result->merchantAccount->masterMerchantAccount->status; // "active" } else { return; } } fd_create_sm(); ?> 

webhooks.php

 <?php var_dump($_POST['bt_signature']); var_dump($_POST['bt_payload']); print_r($_POST['bt_signature']); print_r($_POST['bt_payload']); ?> 
+5
source share
1 answer

Most likely, the received data is stored in some output buffer. If you are sure you want to debug your code this way, try adding a call to wp_die(); immediately after outputting data using print_r . This should help!

One more thing: sometimes some of the code (not in this particular case) is actually never output due to a more complex data stream. In this case, it would be nice to use some third-party debugging tools, or if you are looking for a simpler solution, you can write some of the output to some kind of log file and then check the file.

Good luck

0
source

Source: https://habr.com/ru/post/1239154/


All Articles