![]() |
PHP Issue: How Do I insert raw HTML into .PHP scripts? The situation is like this: I am using a shopping cart script that is coded in .php , and I want to add on a google analytic script to the index.php . How do I actually add the raw html coding into the .php file? Regards, Ed |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? If it's inside the PHP code you should use something like: echo '<b>this is html'; If it's outside, you can simply put it straight away. |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? This is a simple request, but you will need to do this somewhere suitable in the script - I.E somewhere that is not in a loop, and if statement and such. If you want to do this at the end of the script, you can do this after the closing PHP tag, which is ?> - however, this may not be the best place for it. If you need to insert it before the end of the PHP script, you will need to close the tag; ?> Paste in your HTML and then reopen the tags <?php Alternatively, and this may be the safer option for you, if you do not want to break the php tags you can simply do the following in a suitable location. print <<<GACODE paste your GA code in here GACODE; If the index.php has a footer section, this would be an ideal location, just before the closing </html> tag. |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? Quote:
echo '<b>this is html'; <html> <etc. etc. etc.> </html> ? paste anywhere within the script? |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? Quote:
Ed |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? EDIT: Changed. You simply need to paste your Google Analytics code inside the print statement. print <<<GACODE paste your Google Analytics Code in here. or any HTML for that matter. GACODE; |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? For example: ......require($template->get_template_dir('main_template_vars.php',DIR_WS_ TEMPLATE, $current_page_base,'common'). '/main_template_vars.php'); /** * Read the "on_load" scripts for the individual page, and from the site-wide template settings * NOTE: on_load_*.js files must contain just the raw code to be inserted in the <body> tag in the on_load="" parameter. * Looking in "/includes/modules/pages" for files named "on_load_*.js" */ $directory_array = $template->get_template_part(DIR_WS_MODULES . 'pages/' . $current_page_base, '/^on_load_/', '.js'); foreach ($directory_array as $value) { $onload_file = DIR_WS_MODULES . 'pages/' . $current_page_base . '/' . $value; $read_contents=''; $lines = @file($onload_file); foreach($lines as $line) { $read_contents .= $line; } $za_onload_array[] = $read_contents; } * print <<<GACODE <script EXAMPLE EXAMPLE EXAMPLE </script> ...... Like that above? Thanks.. Ed Quote:
|
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? Quote:
print <<<GACODE <script EXAMPLE EXAMPLE EXAMPLE </script> GACODE; ( However - i thought analytics usually went towards the end of the page, I.E before </body> or </html> - i'm not sure if it matters where you put it since i don't use it ) |
Re: PHP Issue: How Do I insert raw HTML into .PHP scripts? Think people have their own way of doing this and might be confusing. Send the file to me, tell me exactly where you'd like it and I'll send it back with code inserted. Don't thank me, just give me money (joke) :) |
| All times are GMT -6. The time now is 02:43 AM. |