PHP Return by Reference

Malhar Lathkar
Updated on 18-Sep-2020 12:16:07

1K+ Views

IntroductionIn PHP,   a function can also be made to return a reference. This is useful  to find to which variable a reference should be bound. To define a function which returns reference, prefix its name by & sign.ExampleIn following example, myfunction() is defined to return by reference. It contains a static variable whose reference is returned and assigned to a global variable. Value of local static variable will also change its reference ouside is assigned with different value.Example Live DemoOutputThis example gives following outputx Inside function: 10 returned by reference: 10 x Inside function: 20method returning referenceA class can also ... Read More

PHP Passing by Reference

Malhar Lathkar
Updated on 18-Sep-2020 12:13:27

12K+ Views

IntroductionIn PHP,  arguments to a function can be passed by value or passed by reference. By default, values of actual arguments are passed by value to formal arguments which become local variables inside the function. Hence, modification to these variables doesn't change value of actual argument variable.When arguments are passed by reference, change in value of formal argument is reflected in actual argument variable because the former is a reference to latter. Thus pass by reference mechanism helps in indirectly manipulating data in global space. It also helps in overcoming the fact that a function can return only one variable.Pass ... Read More

PHP References

Malhar Lathkar
Updated on 18-Sep-2020 12:10:17

5K+ Views

IntroductionIn PHP, References enable accessing the same variable content by different names. They are not like pointers in C/C++ as it is not possible to perform arithmetic oprations using them. In C/C++, they are actual memory addresses. In PHP in contrast, they are symbol table aliases. In PHP, variable name and variable content are different, so the same content can have different names. A reference variable is created by prefixing & sign to original variable. Hence $b=&$a will mean that $b is a referewnce variable of $a.Assign By ReferenceIn following example, two variables refer to same valueExample Live DemoOutputChange in value ... Read More

Use Selenium WebDriver to Click Google Search

Debomita Bhattacharjee
Updated on 18-Sep-2020 12:06:55

16K+ Views

We can click on Google search with Selenium webdriver. First of all we need to identify the search edit box with help of any of the locators like id, class, name, xpath or css.Then we will input some text with the sendKeys() method. Next we have to identify the search button with help of any of the locators like id, class, name, xpath or css and finally apply click() method on it or directly apply submit() method. We will wait for the search results to appear with presenceOfElementLocatedexpected condition.We need to import org.openqa.selenium.support.ui.ExpectedConditions and import org.openqa.selenium.support.ui.WebDriverWait to incorporate expected conditions ... Read More

PHP Server

Malhar Lathkar
Updated on 18-Sep-2020 12:05:38

4K+ Views

Introduction$_SERVER is a superglobal that holds information regarding HTTP headers, path and script location etc. All the server and execution environment related information is available in this associative array. Most of the entries in this array are populated by web server.PHP versions prior to 5.4.0 contained $HTTP_SERVER_VARS contained same information but has now been removed. Following are some prominent members of this arrayPHP_SELF − stores filename of currently executing script. For example, a script in test folder of document root of a local server returns its path as follows −ExampleThis results in following output in browser with http://localhost/test/testscript.php URL/test/testscript.phpSERVER_ADDR − This ... Read More

What Does WebElement Clear Do to Textboxes?

Debomita Bhattacharjee
Updated on 18-Sep-2020 12:02:29

2K+ Views

We can erase the contents from text boxes with Selenium webdriver. This is done with the clear() method. This method clears the edit box and also makes the field enabled.First of all we need to identify the element with help of any of the locators like id, class, name, xpath or css and then apply sendKeys() method to type some text inside it. Next we shall apply the clear() method on it. To check if the edit box got cleared, we shall use getAttribute() method and pass value parameter as an argument to the method. We shall get blank value ... Read More

Get Text from Selenium WebElement Object

Debomita Bhattacharjee
Updated on 18-Sep-2020 11:58:38

8K+ Views

We can get text from a webelement with Selenium webdriver. The getText() methods obtains the innerText of an element. It fetches the text of an element which is visible along with its sub elements. It ignores the trailing and leading spaces.First of all we need to identify the element with help of any of the locators like id, class, name, xpath or css and then apply getText() method on it to get the text content of the element.Let us get the text of the element About Careers at Tutorials on the page−Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import ... Read More

PHP Visibility Modes

Malhar Lathkar
Updated on 18-Sep-2020 11:56:56

3K+ Views

IntroductionIn PHP, it is possible to have a user-defined compund data type using class keyword. A new instance of class is an object. Charactersitics of object are as per definition of class, which may contain property, constant and method members.Accessibility (also called visibility) of a class member depends on visibility prefix keyword attached in its definition. PHP has three visibility keywords - public, private and protected. A class member declared with public keyword is accessible from anywhare. A protected member is accessible from within its class and by inheriting class. On the other hand, a private member can only be ... Read More

Check Element for Specific Class Attribute Using Selenium

Debomita Bhattacharjee
Updated on 18-Sep-2020 11:49:28

6K+ Views

We can check if an element contains a specific class attribute value. The getAttribute() method is used to get the value of the class attribute. We need to pass class as a parameter to the getAttribute() method.First of all we need to identify the element with help of any of the locators like id, class, name, xpath or css. Then obtain the class value of the attribute. Finally, we need to check if the class attribute contains a specific value.Let us take an element with the below html code having class attribute. The tp-logo is the value of the class ... Read More

PHP Late Static Bindings

Malhar Lathkar
Updated on 18-Sep-2020 11:48:26

288 Views

IntroductionThis feature of late static binding in PHP is used to refercalled class in static inheritance. When static methods are called, name of class is attached with scope resolution operator (::) while in case of other instance methods we call them using name of object. The static:: will not be resolved using the class in which method is defined ,instead will be computed using runtime information. Static references to the current class are resolved using the class in which the function belongs, not where it was definedExampleIn following code, parent class calls static ethod with self:: prefix. Same method when ... Read More

Advertisements