Jump to content
php.lv forumi

config.php


GARAIS

Recommended Posts

Uztaisi php failu, kuru pieprasi kā javascriptu un kurā json formā izvadi savu configu.

<?php header("Content-type: application/x-javascript"); ?>
var Config = <?php echo json_encode($config); ?>;

 Pievieno šo failu ar <script> tagu pirms pārējiem failiem.

Un tālāk Config.mansparametrs.

Edited by codez
Link to comment
Share on other sites

Tad jātaisa vai nu kāds filtrs, kurš ņem sarakstu ar publiskajiem laukiem un eksportē tos, vai arī hardkodē:

<?php header("Content-type: application/x-javascript"); ?>
var Config = {};
Config.public = <?php echo json_encode($config->public); ?>;
Config.someOther = <?php echo json_encode($config->someOther); ?>;
Config.apiKeys = <?php echo json_encode($config->apiKeys); ?>;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...