Created
February 19, 2026 15:37
-
-
Save pazteddy/ef6ddd08a49b995a75ca72bf9ef22c25 to your computer and use it in GitHub Desktop.
Código base para cargar productos y mensaje de error
This file contains hidden or 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 | |
| function storagePath(): string | |
| { | |
| return __DIR__ . "/storage_products.json"; | |
| } | |
| function loadProducts(): array | |
| { | |
| $path = storagePath(); | |
| $seed = [ | |
| ["id" => 1, "name" => "Laptop", "price" => 1200.00, "stock" => 3], | |
| ["id" => 2, "name" => "Mouse", "price" => 25.00, "stock" => 15], | |
| ]; | |
| $dir = dirname($path); | |
| if (!is_writable($dir)) { | |
| respondError(500, "No se puede crear el archivo de almacenamiento. | |
| La carpeta '$dir' no tiene permisos de escritura. | |
| Asigna permisos de escritura a la carpeta para continuar."); | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment