By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Repeating references

nathj
Expert 100+
P: 938
Hi,

Some programming languages have a WITH statement that allows you to do something like this (psuedo code):

with myobject
.property1 = variable1
.property2 = variable2
.method()
endwith


I know that's a bit rough but hopefully you get the idea. Is this possible in PHP? It would prevent me typing $this-> alot.

Cheers
nathj
Jul 26 '07 #1
Share this Question
Share on Google+
2 Replies


kovik
Expert 100+
P: 1,044
Even in languages that have the WITH statement, it is highly advised against. PHP does not support it at all as it's worthless. If you used it, then how would you differentiate between a global function and a class function?
Jul 26 '07 #2

nathj
Expert 100+
P: 938
Even in languages that have the WITH statement, it is highly advised against. PHP does not support it at all as it's worthless. If you used it, then how would you differentiate between a global function and a class function?
Okay, in the language I used it in the syntax:
object.property=1
object.property2=2
object.method()

would be replaced with

WITH object
.property=1
.property2=2
.method()
ENDWITH

The presence of the '.' indicates that it is a member of the object.

I was developing in Visual FoxPro and I believe VB has something similar. In my old development language the WITH structure speeds up code as it only checks the object once rather than every time. This is increasingly imortant in visual development for desktop apps when you may be manipulating a class several layers down. You only need to define the path to it once.

As it si not in PHP I can't use it. I just thought I would double check here on thescripts.

Cheers
nathj
Jul 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.