vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Javascript/PHP Hybrid Include (https://vborg.vbsupport.ru/showthread.php?t=255809)

GamingDeluxe 12-24-2010 02:41 AM

Javascript/PHP Hybrid Include
 
Was having a right nightmare today trying to include a php file that done alot of processing to display some simple text.

Alas I've just found an Article on vb.org HERE however I think my way in some ways is easier. If a little nasty

Basically the idea is to create a PHP page/script that parses to a javascript document.write function. which will print what ever the hell you like on the page.

The structure is as follows.

hobbies.php
PHP Code:

<?php
$name 
"sam";
$hobby "run";
?>
document.write('<?php "$name loves to $hobby";?>')

This would simply output onto a blank page
sam loves to run

now that its in js you can include it on any page any place by just adding

HTML Code:

<script src="hobbies.php"></script>
it should print what you need correctly. Not sure how in-depth this will work but the basic idea is there if you find the alternative methods a little to hard to get to grips with!

I assume the way it works is that as long as ur server's mime type is setup to parse .php files with the php processor then even if the page your calling it from doesnt allow php directly it thinks its js so lets it go?

Enjoy!


All times are GMT. The time now is 04:23 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01400 seconds
  • Memory Usage 1,712KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete