With() vs Compact() in Laravel
问题 Is there any difference between with() and compact() ? Which one is more efficient ? 回答1: with() is a Laravel function and compact() is a PHP function and have totally different purposes. with() allows you to pass variables to a view and compact() creates an array from existing variables given as string arguments to it. See compact() for more info on this matter. 回答2: with() is a method made available by method from one of their classes while compact() is a method that is available by default