vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Simple php programming question (https://vborg.vbsupport.ru/showthread.php?t=141511)

cashpath 03-08-2007 06:53 PM

Simple php programming question
 
as a PHP newb I have a simple php question.

When you are inserting html code into your PHP document what is the best way to do it?

SHould you

1) leave php whenever you can? Like
Code:

>?  HTML CODE <?
2) or should you echo or ptint your html like

Code:

print " HTML code with a value=\"value\"";
The main reason I am asking is because you are supposed to put quotes around all values in html. SO I guess the real question is what is the best way to hanlde the quotes around the values?

Is it to escape the php? Or to backslash the quote tags EVERY TIME or is there an easier solution?


************************************************** ************************
UPDATE: I think I have found the answer for this. use single quotes on print statements... if this is not the best way let me know.

Thanks

harmor19 03-08-2007 11:25 PM

I use
PHP Code:

echo "HTML code with a value='value' "

It's too much trouble adding slashes.

MarkPW 03-09-2007 01:09 AM

When I want to output a large amount of html, then I tend to close and re-open the php tag. For small amounts, I use single quoted statements - but it's whatever suits you.

JorgeX 03-12-2007 12:04 AM

Yeah, you can do a largest code and put a <?php $something ?>

Like:

PHP Code:

<table width="750" height="24" border="0" align="center">
        <tr>
          <td><div align="center">
              <?php 
    $thumbnaillimit
=10//How many thumbnails would you like to be displayed?
    
include("includes/thumbnails.inc.php");
    
?>
          </div></td>
        </tr>
      </table>    </td>
  </tr>

or with echo:


PHP Code:

<html>
<head>
<title>Problema</title>
</head>
<body>

<?php
echo "Nombre: <strong>".$_REQUEST['nombre']."</strong>";
echo 
"<br>";
switch (
$_REQUEST['estudio']) {
   case 
'Primario':
       echo 
"Nivel de Estudio Primario";
       break;
   case 
'Secundario':
       echo 
"Nivel de Estudio Secundario";
       break;
   case 
'Terciario':
       echo 
"Nivel de Estudio Terciario";
       break;
default:
print 
"No ingres? Nivel de EstudiO";
}
?>

</body>
</html>

Else, you can include a PHP in html like this example:

PHP Code:

<tr>
            <td valign="top" class="totop">&nbsp;<span class="totop"><?php echo($comment); ?></span></td>
          </tr>


Other way, you cant use INCLUDE TAG:

PHP Code:

   <?php include("ad.php"); ?>
    </ br>
        <p>
          <?php include("ad2.php");  ?>
        </p>
      </DIV>

I hope it helps you


All times are GMT. The time now is 03:29 AM.

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.00949 seconds
  • Memory Usage 1,737KB
  • 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
  • (2)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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