Asked  7 Months ago    Answers:  5   Viewed   24 times

It seems like my code works to check for null if I do

if ($tx) 


if (isset($tx))

why would I do the second one when it's harder to write?



I want to point out that everyone's reponse I've read here should have one caveat added:

"isset() will return FALSE if testing a variable that has been set to NULL" (

This means that in some cases, like checking for a GET or POST parameter, using isset() is enough to tell if the variable is set (because it will either be a string, or it won't be set). However, in cases where NULL is a possible value for a variable, which is fairly common when you get into objects and more complex applications, isset() leaves you high and dry.

For example (tested with PHP 5.2.6 with Suhosin-Patch (cli) (built: Aug 17 2008 09:05:31)):

$a = '';
$b = NULL;



Thanks, PHP!

Wednesday, March 31, 2021
answered 7 Months ago

rename your function to something other than "goto". That is a reserved name.

Wednesday, March 31, 2021
answered 7 Months ago

You are using curly quotes.

Replace all the “ ” and ‘ ’ to " and ' respectively.

Wednesday, March 31, 2021
answered 7 Months ago

What's the point of using them at all? Why i can't just create class with all methods, that i need and then set object of this class as property (i.e. what's the convenience of using protocols)?

A single object can conform to multiple protocols, for example it could be both a UITableViewDelegate and a UIAlertViewDelegate. A single class cannot have multiple superclasses (even in languages where this is syntactically legal, we have long known that this creates significant problems, most famously the Diamond Problem).

Who invokes the methods of AppDelegate? Why there is a class for these methods, not a protocol?

The UIApplication invokes the methods. It is a protocol: UIApplicationDelegate. There just happens to be a class that conforms to that protocol.

I read, that delegate methods contains words like "did", "will", "should", "become". So why the methods of ViewController named that way? How it is correlating with delegates?

UIViewController is not a delegate, nor does it have a delegate (well, a transitioning delegate was added in iOS 7, but that doesn't change much). It is a class that is designed to be subclassed. These are methods that are intended to be overridden if you want to know when various events occur. That have similar names because they are called for similar reasons.

Wednesday, September 1, 2021
Boas Enkler
answered 2 Months ago

Why use Guzzle?

First of all Guzzle is an abstraction layer for http request, although it uses cURL by default you can use any other http client that you want:

Does Guzzle require cURL?

No. Guzzle can use any HTTP handler to send requests. This means that Guzzle can be used with cURL, PHP's stream wrapper, sockets, and non-blocking libraries like React. You just need to configure an HTTP handler to use a different method of sending requests

Note: Guzzle has historically only utilized cURL to send HTTP requests. cURL is an amazing HTTP client (arguably the best), and Guzzle will continue to use it by default when it is available. It is rare, but some developers don't have cURL installed on their systems or run into version specific issues. By allowing swappable HTTP handlers, Guzzle is now much more customizable and able to adapt to fit the needs of more developers.

Since you are using Laravel, if by any chances you use any email API then by now you already have Guzzle installed. On your Laravel's composer.json you can see a suggestion:

"suggest": {
    "guzzlehttp/guzzle": "Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~5.3|~6.0).",

Another reason will be reusing code, take a look at the comment made by bogdan the amount of code needed to do a simple http request with cURL. With Guzzle is way more simpler, cleaner, readable and reusable. Its quite easy to create a service that will encapsulate your Http requests.

Guzzle also allows you to do async requests, in a very similar way you do with javascript using promises.

Last but not least, tests! It's way more easier to do tests to your API or create Unit tests for your app and mock the http requests with Guzzle than using cURL. More info about the tests here

BUT if you only want to do only a couple of simple http requests (which doesn't seem to be the case) you don't care about tests and you don't want to have a dependency on Guzzle go for cURL.

Saturday, September 4, 2021
Dave Mateer
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :