vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Really Basic Question about PHP includes (https://vborg.vbsupport.ru/showthread.php?t=160767)

cheat-master30 10-21-2007 07:39 PM

Really Basic Question about PHP includes
 
Note: No scripting is being run using includes by myself, nor anyone else. This is on including plain HTML files, not programs/scripts/etc.

What is the difference between all these ways of writing includes?

On W3Schools, they use this code:

Code:

<?php include("menu.php"); ?>
PHP.net uses this code:

Code:

include 'vars.php';
And some books use this code:

Code:

<?php include "menu.php"; ?>
Some use brackets and speech marks, some quotation marks and some either speech marks or quotations marks without brackets. Is there a specific standard in this respect, or is it a matter of choice which varies from tutorial to tutorial?

The second thing is this. Why do many books go back on what they say about security and Super Globals in later examples?

Marco van Herwaarden 10-22-2007 05:35 AM

These are all valid, but the prefered syntax is:

include("filename");

Dismounted 10-23-2007 06:50 AM

The <?php and ?> tags specify the start and end of where PHP should start processing code.

Opserty 10-23-2007 09:56 AM

Quote:

Originally Posted by cheat-master30 (Post 1365357)
The second thing is this. Why do many books go back on what they say about security and Super Globals in later examples?

The are outdated? or a bit Lazy? or a bit of both :p. The internet may not be the most trusted place but its definitely the most in-line with the current standards and methods. ;)

Oh I and prefer using single quotes inside brackets...it looks far clean then double quotes. include('file.php'); :p

Dismounted 10-23-2007 10:21 AM

Single quotes when not parsing variables, double when.

Opserty 10-23-2007 10:54 AM

Quote:

Originally Posted by Dismounted (Post 1366645)
Single quotes when not parsing variables, double when.

In that case I prefer to leave the single quotes, stick in the variable then re-open them. Shows up far better under syntax highlighting too. :p require_once('functions_'. $file .'.php');


All times are GMT. The time now is 02:42 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.01031 seconds
  • Memory Usage 1,720KB
  • 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
  • (3)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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