In this tutorial, we will learn Laravel str class_basename() function Example



Example:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\FileController;
use Illuminate\Support\Str;

class HomeController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $class1 = Str::class_basename('Foo\Bar\Baz');
        
        print_r($class_basename1);
        // output - Baz

        $class2 = Str::class_basename('/Team/Game');
        
        print_r($class_basename2);
        // output - baz.png
    }
}


May this example help you.