- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1046 Articles for PHP
4K+ Views
The controller method you want to use can be added inside the view as shown below – Here App\Http\Controllers\StudentController is the controller and test() is the method we want to call. Example 1 The view is student.blade.php.Here we are calling the controller studentController and the method test(). The method test() is defined inside the studentController as shown below − Student Registration Name ... Read More
10K+ Views
To get the details of the HTTP request you need to make use of the class Illuminate\Http\Request. With the above class, you will be able to fetch the input, cookies, and files from HTTP requests. Now consider the following form – To get all the details from the HTTP request you can do as follows − Example 1 Using $request->all() method Enter the details in the form as shown below − Once you submit it will retrieve all the input data and return an array with data. public function validateform(Request $request) { $input = $request->all(); ... Read More
4K+ Views
The blade is a template engine that helps you to build your view display in Laravel. It also helps you to use PHP code inside the template. The blade templates are saved as filename.blade.php and are stored inside the resources/views/ folder. To understand the above question let us create a view calling the blade template. Inside routes/web.php I have created the following route that is calling the view hello with data ['mymsg' => 'Welcome to Tutorialspoint']. Example 1 Let us see an example for this − Route::get('hello', function () { return view('hello', ['mymsg' => 'Welcome to Tutorialspoint']); ... Read More
8K+ Views
The .env file has the following details − APP_NAME=Laravel APP_ENV=local APP_KEY=base64:BUdhVZjOEzjFihHKgt1Cc+gkQKPoA4iH98p5JwcuNho= APP_DEBUG=true APP_URL=http://localhost LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=test DB_USERNAME=root DB_PASSWORD= BROADCAST_DRIVER=log CACHE_DRIVER=file FILESYSTEM_DRIVER=public QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 MEMCACHED_HOST=127.0.0.1 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 SERVER_ADDR = 127.0.0.1 MAIL_MAILER=smtp MAIL_HOST=mailhog MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" This file is generated when you do your Laravel installation. It has all the common environment variables like APP_NAME, APP_URL, your DB connection, etc. The above environment variables are used inside the config/ folder which holds all ... Read More
11K+ Views
The json_decode() method is a PHP built-in function, which helps to convert a JSON object into a PHP object. It takes the input value as a string and returns a readable PHP object Example 1 Following is an example of the json_decode() method − $studentobj = '{"Neha":35, "Arbaaz":37, "Rehan":43}'; print_r(json_decode($studentobj)); Output The output of the above code is − stdClass Object ( [Neha] => 35 [Arbaaz] => 37 [Rehan] => 43 ) Let us now loop through the final object that we get from json_decode(). Example 2 The JSON object is ... Read More
16K+ Views
Assume we have created a table named students using the CREATE statement as shown below − CREATE TABLE students( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(15) NOT NULL, email VARCHAR(20) NOT NULL, created_at VARCHAR(27), updated_at VARCHAR(27), address ... Read More
6K+ Views
To demonstrate the above, we are going to make use of the below form It has username and password fields. Let us try to get raw form data in the methods shown below −Example 1 Using file_get_contents() file_get_contents() method is a built-in PHP function and it returns the file content into a string format. Now to get raw data of the form you can give the input to the file_get_contents as php://input
3K+ Views
All the routes are stored inside the routes/ folder. If you open routes/web.php you will see the list of routes defined for your application. If you want to work with routes, you need to include the following class − use Illuminate\Support\Facades\Route; The routes/web.php file along with above class is added by default when laravel is installed. Here is a basic route that gets called when you hit the URL http://localhost:8000/. It is called the default route. The view(‘test’) is called when the URL is hit. use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('test'); }); Let us ... Read More
5K+ Views
You can make use of the File facade class. To work with File facade you need to include the class as shown below − use Illuminate\Support\Facades\File; Here is a list of examples that shows how to delete the files from the public folder. The files details in the public folder are as follows – Example 1 To delete files using delete() method from File façade. The delete() method will delete the files given. It can take a single file or an array of files as an input. You can delete a single file from the public folder as ... Read More
10K+ Views
To pass an array as URL parameter you can make use of php built-in function http_build_query(). The http_build_query() returns you an URL-encoded query string. Example 1 Using http_build_query() Following is an example of this method − $data = array( 'field1' => 'test', 'field2' => 'xyz' ); echo http_build_query($data) . ""; Output The output of the above code is − field1=test&field2=xyz The following example shows how to make use of http_build_query() when you have an array and the same needs to pass as a URL parameter.