Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DDSameera's avatar

Object Calling method in laravel

When i create CURL object in different ways. Please look

new CURLFile - it doesn't work

new \CURLFile - it works fine

why we need to put "" for each CURL object. please explain it.

0 likes
5 replies
jlrdw's avatar
jlrdw
Best Answer
Level 75

To pull in namespace, like PDO needs same.

3 likes
jlrdw's avatar

You have to back slash to get the class, it's a namespace.

Like

self::$connection = new \PDO

Not

self::$connection = new PDO

Same for curl.

3 likes
DDSameera's avatar

So we can call that object without specifying use keyword.

Am i right ? @jlrdw

Please or to participate in this conversation.