Is the term "handle" reserved in PHP? [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In my php code, I am writing a class to create log files, and therefore have to work with files. I would like to store the variable $handle as a field, however when I refer to it as $this->handle, "handle" changes color, to indicate that perhaps it is a reserved term.
I looked through the php manual as well as some other online sources and haven't found anywhere saying it is actually reserved. Can someone clear this up for me?
Thanks for your help.
Cheers!
------------- Edit ---------------
It looks like it's recognizing handle as at least 3 static methods...still not sure what the "K" word means. Key?

Not only is it not reserved, but it is a common convention to call resource IDs and more $handle. In fact, you can find it throughout the PHP documentation. For example, fopen.

Related

MongoDB/PHP: search for string with query [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
EDIT: I solved it. Just need to use "MongoDB\BSON\Regex".
I'm storing books as documents in MongoDB, with the individual pages stored as strings in an array. I'm trying to implement a search page that can take a string and return all documents that contain it. Can this be done directly with a MongoDB query called using PHP (i.e searching for a substring within the string arrays)?
I'm using MongoDB\Driver ( http://php.net/manual/en/book.mongodb.php ) because it was the only option that worked on my machine, and I couldn't find detailed documentation or tutorials for this particular driver. Can anyone help?
Something like
db.table.find({"bookTextField": /.*(the string).*/})
EDIT: Of course, replace table by the table name and bookTextField by the field of the table containing the text

Naming functions in PHP [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I looked online and could not find any answer. I'm new to PHP and i've seen so many different ways of naming functions. Namely,
isset <- no underscore
is_integer <- underscore
fooBar <-subsequent words after the first have the first letter capitalized.
In what way do the functions differ in the way they work, such that they are named differently by convention? Or is it some other reason?
Earlier versions of PHP built-in functions had no naming conventions, that's why we have such a zoo. But, no, it does not matter how you name a function as long as you use naming conventions of your team.
If you're making shared public code/library you better stay close to, for example, http://www.php-fig.org/psr/psr-1/ PHP standards

Understanding the Api in PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
a beginner here.
I have already checked the forum to find out answers but I was not successful, my question is specifically on one line of code. So I hope no one will mark my question as duplicate as I am in learning curve. 2 problems here:
What is the meaning of this piece of code? I understand that it is making a new object but is Api a reserved word? What is none for? $user = new Api('none','none');
I understand what is API but could you please introduce any good resource that explains the API for beginners? I do not fully understand the concept of APIs.
Your help is appreciated.
Api is not a reserved keyword in PHP
This is simply creating a new instance of Api, which should be somewhere in your codebase or include path. Look at it's constructor to find out why those parameters are passed.
Also, being a beginner does not excuse you for posting duplicate questions ;)

MySQL Algorithm vs Query [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
You find a lot of info on this online. But not what the exact work around of the use of Algorithm is in MySQL. The real basics, if you will..
What a query is, is obvious, of course. What Algorithm does, remains unclear.
Main reason for this question is: to improve profiling & matching records to known users. (In this case: to match docs in a database to users that need them)
Some examples of the usage of it are highly appreciated!
Algorithm is a keyword used with create view in MySQL. The documentation does a pretty good job of explaining it.
The short answer is that MySQL supports two methods of handling views: either "merging" the view definition in the calling code or creating a temporary table. The first is called MERGE and the second TEMPTABLE. In general, MERGE is faster, but most views are TEMPTABLE because of the restrictions on `MERGE.

How I can get the difference between two text files? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have two text file. I want to compare this two text file and want to create new text file with difference of this 2 files
Old_file.txt Contents:-
XYZ,Desc,46,XYZ,1.6000,0
XYZ1,Desc,56,XYZ1,8.6000,0
XYZ2,Desc,66,XYZ2,10.6000,0
XYZ3,Desc,76,XYZ3,11.6000,0
new_file.txt Contents:-
XYZ,Desc,46,XYZ,1.6000,0
XYZ1,Desc,86,XYZ1,9.6000,0
XYZ2,Desc,66,XYZ2,10.6000,0
XYZ3,Desc,100,XYZ3,11.6000,0
Need file:- (new_file.txt - old_file.txt)
XYZ1,Desc,86,XYZ1,9.6000,0
XYZ3,Desc,100,XYZ3,11.6000,0
Thank You in advance.
You are coping what is usually refered as "longest common subsequence problem", there are a looot of implementations of the most common algorithm. You can spot the solution of your problem working on the script provided here.
You could use the Text_Diff pear package which is pretty robust. There's also the xdiff extension, which you can do this with, using the xdiff_file_diff function
xdiff_file_diff('Old_file.txt', 'new_file.txt', 'diff.txt');
Where diff.txt would be the resulting file with the comparison between the two files.

Categories