⊗ppPmFSRV 356 of 447 menu

Storing Include Result in a Variable in PHP

It is possible to make the result of the included file storable in a variable. For this, the included file must return data via return.

Let's look at an example. Suppose our file returns an array:

<?php return ['a', 'b', 'c', 'd', 'e']; ?>

Let's include this file and store the result of the inclusion in a variable:

<?php $arr = require 'arr.php'; var_dump($arr); ?>

Create a file that will return the names of the days of the week. Include it into a variable in your main file.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline