473,799 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does this produce a parse error?

ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!

Any ideas?

Phil
Jul 16 '05 #1
6 4070
With total disregard for any kind of safety measures "Phil Powell"
<so*****@erols. com> leapt forth and uttered:
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought
this was perfectly valid code structuring in PHP!

Any ideas?


Whoever told you you could do that?

--
There is no signature.....
Jul 16 '05 #2
Phil Powell wrote:
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!

Any ideas?

Phil


For some reason (I don't get it either),
PHP doesn't let you use the result of a built-in function
for operations like indexing.
You'll have to assign the result to a variable,
and index that variable.

The "expecting ')'" part of the error is because the { } are
illegal in this case, since they define a block,
which doesn't result in a return value.

Regards,
Felix

--
the QuiX project
Open Source software

E-Mail: qu**@free.fr
Web: http://www.quix.tk/

Jul 16 '05 #3
"Phil Powell" <so*****@erols. com> wrote in message
news:3GT_a.390$ 3M4.260@lakerea d04...
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!


already said why it can't be done, but I can see what you are trying to
do, so here is an
solution perhaps:

consider:
<?

$var = "this is a test";

print ucfirst(current (explode(" ", $var)));

?>

Will output:
This

something like that you where looking for?

--
Vh
Dennis Friis
IRC: peavey - #linux.dk@under net

Jul 16 '05 #4
Well, as much hate-mail as I'm going to get for saying this, but alas I
shall:

You can do that in Java. You can produce a result and index upon it as the
nature of OOP comes to mind.

I guess PHP isn't as OOP as I thought it was. :(

Phil
"the QuiX project" <qu**@free.fr > wrote in message
news:bh******** **@news.hccnet. nl...
Phil Powell wrote:
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!

Any ideas?

Phil


For some reason (I don't get it either),
PHP doesn't let you use the result of a built-in function
for operations like indexing.
You'll have to assign the result to a variable,
and index that variable.

The "expecting ')'" part of the error is because the { } are
illegal in this case, since they define a block,
which doesn't result in a return value.

Regards,
Felix

--
the QuiX project
Open Source software

E-Mail: qu**@free.fr
Web: http://www.quix.tk/

Jul 16 '05 #5
Ok here we go:

this is my array elements:
$formFieldsArra y = array('username/Username/text/1',
'password1/Password/password/1',
'password2/Password (for verification
purposes)/password/1',
'firstname/First Name/text/0', 'lastname/Last
Name/text/0',
'address1/Address/text/0', 'address2/Address Line
2/text/0',
'city/City/text/0', 'state/State/dropdown/0',
'zip/Zip - Postal/text/0',
'country/Country/dropdown/0',
'homephone/Home Phone/text/0', 'workphone/Work
Phone/text/0',
'fax/Fax/text/0',
'isRegisteredFr omHome/Are you registering from
your home PC?/radio/0');

I want to get "state" and "country", from those parse "state.xml" and
"country.xm l" into simple XML parsing 3-dimensional array structures, and
loop through those structures to populate a dropdown.

Ideas? I can't think of any dynamic way of doing it.

Phil

"Phil Powell" <so*****@erols. com> wrote in message
news:kYW_a.403$ 3M4.194@lakerea d04...
That would work for the first one, (i.e., "This"), but what if I want to get "A" or "Test"?

Phil

"Dennis Friis" <pe******@PAM.p lacid.dk> wrote in message
news:3f******** **************@ nntp03.dk.telia .net...
"Phil Powell" <so*****@erols. com> wrote in message
news:3GT_a.390$ 3M4.260@lakerea d04...
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!


already said why it can't be done, but I can see what you are trying to
do, so here is an
solution perhaps:

consider:
<?

$var = "this is a test";

print ucfirst(current (explode(" ", $var)));

?>

Will output:
This

something like that you where looking for?

--
Vh
Dennis Friis
IRC: peavey - #linux.dk@under net


Jul 16 '05 #6
"Phil Powell" <so*****@erols. com> wrote in message
news:3GT_a.390$ 3M4.260@lakerea d04...
ucfirst({explod e('/', $val)}[0])

This produces a parse error expecting ')', but why? I thought this was
perfectly valid code structuring in PHP!

Any ideas?

Phil


ucfirst({explod e('/', $val)}[0]) - curly brackets??
try
ucfirst(explode ('/', $val)[0]);

Nathan


Jul 16 '05 #7

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

Similar topics

3
3969
by: Bruce W...1 | last post by:
Was browsing the documentation on reading a configuration file and found this. What does a semicolon do at the beginning of a line? ; <?php DO NOT REMOVE THIS LINE one = 1 five = 5 path = /usr/local/bin ; DO NOT REMOVE THIS LINE ?>
7
1761
by: chotiwallah | last post by:
suppose i have the following code: switch ($inc): case 0: require 'inc0.php'; break; case 1: require 'inc1.php'; break; case 2:
4
3446
by: WJA | last post by:
I'm probably missing something here but I can't understand the following. When 2 users try to save a record with the same primary key (a number field), the first record saves as expected, but the second does not produce an error. The "Save" button uses "Docmd.Save" to save the record. If I insert "Me.Dirty = False" before "Docmd.Save" an error is produced. Why doesn't "Docmd.Save" produce an error but instead silently fails to save the...
15
6735
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int i = 0,j; j = sample(0);
4
4820
by: antonyliu2002 | last post by:
I have the following simple code to test if my session is working: <Script Runat="Server"> Sub LinkButtonGenInfo_Click(s As Object, e As EventArgs) If txtFirstName.Text <> Nothing Then Session("firstName")=txtFirstName.Text End If If txtFirstName.Text <> Nothing Then lblYourName.Text=Response.Write(Session("firstName"))
10
4902
by: Viken Karaguesian | last post by:
Hello everyone, Me again. Trying to learn some more :>) I hope I got the terminology right. How does a browser parse (correct term?) an HTML document. I'm sure that every browser does it a little differently. Do they simply just read a document top-to-bottom and left-to-right and just display elements in the order in which they encounter them? Or, do they give priority to certain types of content? For instance, would a browser
7
2145
by: GS | last post by:
Hello, I'm receiving The state information is invalid for this page and might be corrupted error message when running code below. This happens on second post back. Why is it happening? My webpage contains 2 dropdowns controls and I save information entered by user in ViewState variable containing array ArrayList MyCoordinates = (ArrayList) ViewState ; if (MyCoordinates == null) { MyCoordinates = new ArrayList ();
3
2151
by: Cor Pruim | last post by:
I have a very strange problem. I have written a Windows Service with VS2003 in vb.net. This service does some calculations and after that it needs to produce some Excel reports by getting data from an Oracle database. This has been working fine for two years and it still is working fine in our production environment. But after installing a new test server the problems started. I did many tests but there is something strange. When I start the...
13
2581
blazedaces
by: blazedaces | last post by:
Hey guys, how's it going today? So basically I have a program that uses hotbits (a real online random number generator based off radioactive decay) to produce truly random alphanumeric codes (Note: the program is the package randomX from their website). Since I needed many codes I ran the program last night and then all of a sudden it spit out the following error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:...
0
9541
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
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10225
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
10027
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
9072
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
7564
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...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2938
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.