473,598 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Type of Data Returned by a Function

I've noticed that some code analyzers comment that the type of data
returned by my functions is "unknown" in the following syntax:

function fnFooBar($aryPa rameters) {
$bRetVal = True;
return $bRetVal;
}

I *think* I can specify that by doing something like this:

function fnFooBar($aryPa rameters) bool {
$bRetVal = true;
return $bRetVal;
}

Is this correct?
If so, is there a performance gain, or is it just clean coding?
Jul 20 '07 #1
2 1323
On Jul 20, 6:32 pm, Sanders Kaufman <bu...@kaufman. netwrote:
I've noticed that some code analyzers comment that the type of data
returned by my functions is "unknown" in the following syntax:

function fnFooBar($aryPa rameters) {
$bRetVal = True;
return $bRetVal;

}

I *think* I can specify that by doing something like this:

function fnFooBar($aryPa rameters) bool {
$bRetVal = true;
return $bRetVal;

}

Is this correct?
If so, is there a performance gain, or is it just clean coding?
You think you can? Did you even try it? If you did you'd quickly
find that you get a syntax error.

That syntax isn't supported by PHP, and, as far as I know, there is no
way to specify the type of data returned. As such, I'm not sure what
your code analyzer expects you to do about it or why it would complain
about it in the first place.

Jul 21 '07 #2
Sanders Kaufman wrote:
function fnFooBar($aryPa rameters) bool {
$bRetVal = true;
return $bRetVal;
}

Is this correct?
No -- PHP doesn't have any method for declaring a function's return type.
(As of PHP 5 there is a limited facility for declaring the types of
parameters a function accepts, but still nothing for the return type.)

Your "code analyzers" might be able to determine return type using a
phpDoc-style comment. (Google: phpDoc.)

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 30 days, 5:45.]

Parsing an HTML Table with PEAR's XML_HTTPSax3
http://tobyinkster.co.uk/blog/2007/0...table-parsing/
Jul 21 '07 #3

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

Similar topics

8
3072
by: DaKoadMunky | last post by:
Please consider the following... <CODE> #include <string> using namespace std; typedef int PrimitiveType; typedef string ClassType;
4
2053
by: Mark | last post by:
Hi.. I have a c# class that i'm using to implement some extension functions and one of those functions is a simple push/pop stack. I made the c# code fairly generic, taking and returning objects - i.e public void push (object val { stack.Push (val) public object pop ( { return stack.Pop()
4
25410
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me what's wrong regards I get this error:
100
5214
by: E. Robert Tisdale | last post by:
What is an object? Where did this term come from? Does it have any relation to the objects in "object oriented programming"?
1
2713
by: Ravi | last post by:
HI all, we r using db2 V 8.2, when i am trying to change data type ie. SMALLINT to INTEGER(no data in the table), iam getting this error messege. Pl. help me slove the error. ERROR is SQL0443N Routine "ALTOBJ" (specific name "") has returned an error SQLSTATE with diagnostic text "SQL1013 Reason code or token: dbname ". SQLSTATE=38553
2
14762
by: John | last post by:
My application needs to call Oracle function using oracle client 9.2. The oracle function returns boolean value from its returned parameter. The name space that I used is system.data.oracleclient. found out there is no boolean type in Oracle parameter in OracleType. How can I get the returned value from function call in my code? Thanks in advance
7
2850
by: Arpan | last post by:
The .NET Framework 2.0 documentation states that An Object variable always holds a pointer to the data, never the data itself. Now w.r.t. the following ASP.NET code snippet, can someone please explain me what does the above statement mean? <script runat="server"> Class Clock
1
10466
by: jmarr02s | last post by:
I am trying to change my Amount column Data Type from Integer to Decimal (precision 9 digits, scale 3, that is 6 digits to the left of decimal and 3 digits to the right of decimal. Here is the error message I received SQL0443N Routine "SYSPROC.ALTOBJ" I sense this is a security issue, something my DBA must resolve and some aspect I do not have permission to do? Thanks,
16
6410
by: The Frog | last post by:
Hi Everyone, I have a small problem that doesnt seem to make any sense. I am using Access 97, and have a query that selects data from a text field, converts it to type Lng. This seems to work fine. When I try and apply a criteria for filtering is get the data type mismatch rubbish that Access likes to trow at you. Here is the SQL:
0
7981
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8284
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
8046
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
5437
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
3894
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...
0
3938
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2410
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
1
1500
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1245
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.