How to pass `?` with url in laravel?

Member

by gilbert , in category: PHP Frameworks , 10 months ago

How to pass `?` with url in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by elisha_langworth , 6 months ago

@gilbert 

In Laravel, you can pass ? (question mark) with a URL by using the url() helper function provided by Laravel.


For example:

1
$url = url('example/url?param1=value1&param2=value2');


This will generate a URL like http://yourdomain.com/example/url?param1=value1&param2=value2.


You can also pass parameters as an array and let Laravel handle encoding them for you:

1
$url = url('example/url', ['param1' => 'value1', 'param2' => 'value2']);


This will generate the same URL as above.


Make sure to properly encode special characters before passing them in the URL to avoid any issues. Laravel will handle encoding the parameters for you when constructing the URL.

Related Threads:

How to pass value in url in laravel?
How to pass variable in url in codeigniter?
How to pass an array from a form into a url with javascript?
How to pass props in the url in react.js?
How to pass hash into url from page to iframe?
How to pass parameter through href in laravel?