Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2007, 06:53 PM
cashpath cashpath is offline
 
Join Date: Jul 2003
Posts: 216
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 03-08-2007, 11:25 PM
harmor19 harmor19 is offline
 
Join Date: Apr 2005
Posts: 1,324
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I use
PHP Code:
echo "HTML code with a value='value' "
It's too much trouble adding slashes.
Reply With Quote
  #3  
Old 03-09-2007, 01:09 AM
MarkPW MarkPW is offline
 
Join Date: Apr 2006
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 03-12-2007, 12:04 AM
JorgeX JorgeX is offline
 
Join Date: Oct 2005
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:30 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.06142 seconds
  • Memory Usage 2,204KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete