Last active
March 19, 2023 04:06
-
-
Save sebastopolys/101dd7c0e1ce3469d52994daf9c287be to your computer and use it in GitHub Desktop.
Alternative switch statement for PHP Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Yournamespace; | |
class GetTemplates{ | |
/* | |
* dirname(__DIR__)./templates/ is your templates path | |
* $layout_id is file name | |
*/ | |
public static function section($section,$layout_id){ | |
$root = file_get_contents(dirname(__DIR__) . '/templates'.'/'.$layout_id.'.html'); | |
$section_act = file_get_contents(__DIR__) . '/templates'.'/'.$layout_id.'.html'); | |
$item_cont = file_get_contents(__DIR__) . '/templates'.'/'.$layout_id.'.html'); | |
$item = file_get_contents(dirname(__DIR__) . '/templates'.'/'.$layout_id.'.html'); | |
if($$section!==null){ | |
return $$section; | |
} | |
return "File not found Error"; | |
} | |
} | |
// Instantiate e.g. | |
// returns $section_act | |
GetTemplates::section('section_act',$layout)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment