I want to load css file from app/asset/css/tes.css This is my css file
I tried many ways but still couldn't. Please help me
I want to access the CSS file for the lala.php in the view folder, by saving the CSS file in the assets folder
I want to load css file from app/asset/css/tes.css This is my css file
I tried many ways but still couldn't. Please help me
I want to access the CSS file for the lala.php in the view folder, by saving the CSS file in the assets folder
The problem is with your path in the controller. The correct path should be:
$path = FCPATH . '../app/asset/css/tes.css';
Or a cleaner way is:
$path = APPPATH . 'asset/css/tes.css';
Edit: I assumed file_as_string()
is a core PHP function, but it actually is from my Common.php
file:
file_as_string:
if (! function_exists('file_as_string')) {
/**
* Returns the files' content as string or empty string on failure.
*/
function file_as_string(string $path): string
{
$filePath = $path;
try {
$fileContent = file_get_contents($filePath);
} catch (ErrorException $e) {
return '';
}
if ($fileContent) {
return $fileContent;
}
return '';
}
}
I use the following in my view file, but you could easily use it someplace else.
Example:
<style><?= file_as_string(APPPATH . 'asset/css/test.css') ?></style>
file_as_string()
a built in or codeigniter specific function?
Commented
Jul 4 at 19:51
file_as_string
comes from. Edited my answer for clarity.
Commented
Jul 5 at 7:14