473,659 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very fast php variable access in html

Dear Group,

In the past I read something, that it is possible to print out php
variables in html very fast with a simple symtax.

Today I came back to php documentation, but I cannot find it anymore

Its something like

<?php

echo $variable ;

?>

just much shorter.

Can anybode help me ?
Jun 2 '08 #1
5 1836
Guenther Sohler schrieb:
Its something like

<?php
echo $variable ;
?>

just much shorter.
<?=$variable? >

See http://de3.php.net/echo

But it works only if short open tags are enabled - and unless you have
full control over the PHP config (php.ini), you cannot rely upon this.
And even if - your code would not be portable.

Alternatives:
<?php o($variable) ?>
with function o ( $variable ) { echo $variable; } or
<?php $view->variable ?>
with function __get ( $what ) { echo $this->$what; }

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux Ã* avoir tort qu'ils ont raison!
(Coluche)
Jun 2 '08 #2
Guenther Sohler wrote:
Dear Group,

In the past I read something, that it is possible to print out php
variables in html very fast with a simple symtax.

Today I came back to php documentation, but I cannot find it anymore

Its something like

<?php

echo $variable ;

?>

just much shorter.

Can anybode help me ?
You may be thinking of <?= $variable; ?>

But this requires short_open_tag be enabled, which can conflict with
xml. Most hosts have it off now.

And the difference in speed printing the variable is virtually
unmeasurable. So it only really makes a difference to the programmer.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #3
Thomas Mlynarczyk schrieb:
Alternatives:
<?php o($variable) ?>
with function o ( $variable ) { echo $variable; } or
<?php $view->variable ?>
with function __get ( $what ) { echo $this->$what; }
Another possible solution might be the heredoc syntax:

echo <<< EOT
<body>
<h1>$title</h1>
<p>$text</p>
</body>
EOT;

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux Ã* avoir tort qu'ils ont raison!
(Coluche)
Jun 2 '08 #4
On Sat, 17 May 2008 15:07:35 +0200, Thomas Mlynarczyk
<th****@mlynarc zyk-webdesign.dewro te:
Thomas Mlynarczyk schrieb:
>Alternatives :
<?php o($variable) ?>
with function o ( $variable ) { echo $variable; } or
<?php $view->variable ?>
with function __get ( $what ) { echo $this->$what; }

Another possible solution might be the heredoc syntax:

echo <<< EOT
<body>
<h1>$title</h1>
<p>$text</p>
</body>
EOT;
That last one is something I definitly use often for smaller sites,
however, your first solution seems quite useless as a simple echo would
suffice as well. Defining obscure functions just to save typing 5
characters every coder knows and understands does not only souns useless
to me, as far as I am concerned I consider this very bad practise.
--
Rik Wasmus
....spamrun finished
Jun 2 '08 #5
Rik Wasmus schrieb:
>Thomas Mlynarczyk schrieb:
>>Alternative s:
<?php o($variable) ?>
with function o ( $variable ) { echo $variable; } or
<?php $view->variable ?>
with function __get ( $what ) { echo $this->$what; }
however, your first solution seems quite useless as a simple echo would
suffice as well. Defining obscure functions just to save typing 5
characters every coder knows and understands does not only souns useless
to me, as far as I am concerned I consider this very bad practise.
True, o() is just syntactic sugar, but as the OP didn't want to use
echo... Personally, I prefer the second variant. The disadvantage of
using heredoc is that you cannot, e.g., loop over an array to produce
table rows within the heredoc.

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
Jun 2 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
17551
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time to load making any kind linkage with my Access data virtually useless. I have the MySQL driver setup in as a USER DSN. The MySQL data is sitting out on a server and the Access database is running locally. The network connection is very...
1
1819
by: Avi | last post by:
Hi All. This code works very fine in Firefox but not in I.E. Can anybody help me out? it gives ... "Unknown Runtime Error" in I.E. This code ... Stores N*2 Matrix at Client Side & provide the mean to send the matrix to server side. =======================================================
6
8185
by: Rafi Kfir | last post by:
HI, I use vb6 to access database. I can select between "local" data base and "remote" data base. Both connection calls the same Access 2000 Mdb. The Mdb contains local tables (on the hard disk) and remote links to Oracle tables via odbc link. The local connection (to the recordset) is fast, but the "remote" connection takes around 7 minuits.
10
1861
by: Jason Curl | last post by:
Greetings, I have an array of 32 values. This makes it extremely fast to access elements in this array based on an index provided by a separate enum. This array is defined of type "unsigned long int". I have a typedef for this: typedef unsigned long int Uint32; typedef float Float32; Uint32 myArray;
20
9142
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg., int_fast32_t 4) integer capable of holding a pointer, intptr_t 5) widest integer in the implementation, intmax_t Is there a valid motivation for having both int_least and int_fast?
14
1715
by: Steve | last post by:
Sorry in advance for my ignorance. Any help would sure be appreciated. I'm writing a fairly simple application with VB.Net and am obviously a bit of a newbie. This application will be used by 1, 2 or at most 3 people concurrently and I'm using Access 2003 for my data source. We are not dealing with a large amount of data (5 or 6 tables, for a total of maybe 3,000 records - one table having the majority of that). This application is...
4
7891
by: Volker Jobst | last post by:
Hi, Is there a really fast way to read a text file which contains lines of variable length? I'm using the StreamReader to read the file, but this is not as fast as I need it. thanks a lot volker jobst
13
4510
by: Arno R | last post by:
Hi all, I am deploying an A2k app to users with different versions of Access. Using Access 2000 the relinking on startup (on deploying a new frontend or when backend has changed) is very fast. It takes about 4-5 seconds to relink some 50 tables. (I am relinking, not refreshing) Using Access 2003 the relinking is very slow compared with Access 2000. Now It takes about 1,5 to 2 minutes !! to relink the same 50 tables. I am testing...
11
2005
by: John Sheppard | last post by:
Hello there, I am running a webservice on IIS6, sometimes it runs at a reasonable speed, sometimes it runs painfully slow and sometimes inbetween. The application that consumes the service is vb.dotnet and runs on a local area network. Does anyone have any ideas? Where should I start to look? What could be causing this? Thank you for any help or ideas
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.