当前位置:文档之家› invoke的用法

invoke的用法

invoke的用法
invoke的用法

invoke

英[?n?v??k] 美[?n?vo?k]

vt.乞灵,祈求;提出或授引…以支持或证明;召鬼;借助

网络

调用;恳求;祈求;唤起

过去式:invoked 过去分词:invoked 现在分词:invoking 第三人称单数:invokes

派生词:invoker 报错

语源

late 15th cent.: from French invoquer, from Latin invocare, from in- 'upon' + vocare 'to call'

柯林斯高阶英汉双解学习词典

英汉双向大词典

vt.

1. 援引, 援用;行使(权利等)(法律、规则等作为行动理由)

She had invoked the law in her own defence.

她援引法律为自己辩护。

2. 向(某人)请求帮助;(尤指)祈求神助

3. 恳求;乞求

She invoked their help.

她恳求他们帮忙。

vt. & vi.

1. 提及,援引(某人、某理论、实例等作为支持)

2. 提出(某人的名字,以激发某种感觉或行动)

3. 使产生,唤起,引起(感情或想像)

4. 使用;应用

5. . 调用;激活

6. 用法术召唤(魔鬼)

英英释义

行业释义

网络释义

Verb

1. evoke or call forth, with or as if by magic;

2. cite as an authority; resort to;

3. request earnestly (something from somebody); ask for aid or protection;

词根:vok

=call/voice,表示"出声,叫喊,看"

同根词

adj.

invocatory祈求的, 祈愿的(invoc=invoke[v.祈求,恳求,[法律的]实施生效]+atory表形容词→adj.祈求的, 祈愿的)

revocable可废除的(revoc=revoke[v.废除,取消]+able能……的→adj.可废除的) provocative激怒的,挑战的(provoc=provoke[v.激怒,刺激]+ative……的→adj.激怒的,挑战的) n.

equivoke双关语, 含糊措辞(equi平等+vok出声,叫喊,看+e→有两种声音→双关语)

invoke祈求,恳求,[法律的]实施生效(in进+vok出声,叫喊,看+e→喊进去,请求) convoke召集[会议] (con共同+vok出声,叫喊,看+e→喊到一起→召集)

evoke唤起[回忆,感情等];引起(e出+vok出声,叫喊,看+e→喊出思想等)

JAVA中Method的Invoke方法

Java中Method的Invoke方法 在写代码的时候,发现从父类class通过getDeclaredMethod获取的Method可以调用子类的对象,而子类改写了这个方法,从子类class通过getDeclaredMethod也能获取到Method,这时去调用父类的对象也会报错。虽然这是很符合多态的现象,也符合java的动态绑定规范,但还是想弄懂java是如何实现的,就学习了下Method的源代码。 Method的invoke方法 1.先检查 AccessibleObject的override属性是否为true。 AccessibleObject是Method,Field,Constructor的父类,override属性默认为false,可调用setAccessible方法改变,如果设置为true,则表示可以忽略访问权限的限制,直接调用。 2.如果不是ture,则要进行访问权限检测。用Reflection的quickCheckMemberAccess方法先检查是不是public的,如果不是再用Reflection.getCallerClass(1)方法获 得到调用这个方法的Class,然后做是否有权限访问的校验,校验之后缓存一次,以便下次如果还是这个类来调用就不用去做校验了,直接用上次的结果,(很奇怪用这种方式缓存,因为这种方式如果下次换个类来调用的话,就不用会缓存了,而再验证一遍,把这次的结果做为缓存,但上一次的缓存结果就被冲掉了。这是一个很简单的缓冲机制,只适用于一个类的重复调用)。 3.调用MethodAccessor的invoke方法。每个Method对象包含一个root对象,root对象里持有一个MethodAccessor 对象。我们获得的Method独享相当于一个root对象的镜像,所有这类Method共享root里的MethodAccessor对象,(这个对象由ReflectionFactory方法生成,ReflectionFactory对象在Method类中是static final的由native方法实例化)。ReflectionFactory生成MethodAccessor:如果noInflation的属性为true则直接返回MethodAccessorGenerator创建的一个MethodAccessor。否则返回DelegatingMethodAccessorImpl,并将他与一个NativeMethodAccessorImpl互相引用。但DelegatingMethodAccessorImpl执行invoke方法的时候又委托给NativeMethodAccessorImpl了。 再一步深入 4.NativeMethodAccessorImpl的invkoe方法: 调用natiave方法invoke0执行方法调用. 注意这里有一个计数器numInvocations,每调用一次方法+1,当比 ReflectionFactory.inflationThreshold(15)大的时候,用MethodAccessorGenerator创建一个MethodAccessor,并把之前的DelegatingMethodAccessorImpl引用替换为现在新创建的。下一次DelegatingMethodAccessorImpl就不会再交给NativeMethodAccessorImpl执行了,而是交给新生成的java字节码的MethodAccessor。 MethodAccessorGenerator使用了asm字节码动态加载技术,暂不深入研究。 总结一个方法可以生成多个Method对象,但只有一个root对象,主要用于持有一个MethodAccessor对象,这个对象也可以认为一个方法只有一个,相当于是static的。因为Method的invoke是交给MethodAccessor执行的,所以我所想要知道的答案在MethodAccessor的invoke中,深入MethodAccessor:

android中的Intent的用法和原理属性

android中的Intent的用法和原理属性 2010-06-10 17:18:52| 分类:android|字号订阅 Android中提供了Intent机制来协助应用间的交互与通讯,Intent负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述,Android则根据此Intent的描述,负责找到对应的组件,将 Intent传递给调用的组件,并完成组件的调用。Intent不仅可用于应用程序之间,也可用于应用程序内部的Activity/Service之间的交互。因此,Intent在这里起着一个媒体中介的作用,专门提供组件互相调用的相关信息,实现调用者与被调用者之间的解耦。在SDK中给出了Intent作用的表现形式为: 通过Context.startActivity() orActivity.startActivityForResult() 启动一个Activity; 通过 Context.startService() 启动一个服务,或者通过Context.bindService() 和后台服务交互; 通过广播方法(比如 Context.sendBroadcast(),Context.sendOrderedBroadcast(), Context.sendStickyBroadcast()) 发给broadcast receivers。 Intent属性的设置,包括以下几点:(以下为XML中定义,当然也可以通过Intent类的方法来获取和设置) (1)Action,也就是要执行的动作 SDk中定义了一些标准的动作,包括 onstantTarget componentAction ACTION_CALLactivityInitiate a phone call. ACTION_EDITactivityDisplay data for the user to edit. ACTION_MAINactivityStart up as the initial activity of a task, with no data input and no returned output. ACTION_SYNCactivitySynchronize data on a server with data on the mobile device. ACTION_BATTERY_LOWbroadcast receiverA warning that the battery is low. ACTION_HEADSET_PLUGbroadcast receiverA headset has been plugged into the device, or unplugged from it. ACTION_SCREEN_ONbroadcast receiverThe screen has been turned on. ACTION_TIMEZONE_CHANGEDbroadcast receiverThe setting for the time zone has changed. 当然,也可以自定义动作(自定义的动作在使用时,需要加上包名作为前缀,如"com.example.project.SHOW_COL OR”),并可定义相应的Activity来处理我们的自定义

InvokeRequired 属性 与Invoke方法

在设计中为了让界面与逻辑分离,我的做法是使用事件,界面只要响应事件来处理界面的显示就行了。而事件在逻辑处理中可能由不同的线程引发,这些事件的响应方法在修改界面中的控件内容时便会引发一个异常。 这时就用到了Control.InvokeRequired 属性与Invoke方法。 MSDN中说: 获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用Invoke 方法,因为调用方位于创建控件所在的线程以外的线程中。 如果控件的Handle 是在与调用线程不同的线程上创建的(说明您必须通过Invoke 方法对控件进行调用),则为true;否则为false。 Windows 窗体中的控件被绑定到特定的线程,不具备线程安全性。因此,如果从另一个线程调用控件的方法,那么必须使用控件的一个Invoke 方法来将调用封送到适当的线程。该属性可用于确定是否必须调用Invoke 方法,当不知道什么线程拥有控件时这很有用。 下面来说下这个的用法(我的一般做法): 首先定义一个委托,与这个事件处理函数的签名一样委托,当然直接使用该事件的委托也是可以的,如: private delegate void InvokeCallback( string msg); 然后就是判断这个属性的值来决定是否要调用Invoke函数: void m_comm_MessageEvent( string msg) { if (txtMessage.InvokeRequired) { InvokeCallbackmsgCallback = new InvokeCallback(m_comm_MessageEvent); txtMessage.Invoke(msgCallback, new object [] { msg } ); } else { txtMessage.Text = msg; } } 说明:这个函数就是事件处理函数,txtMessage是一个文本框。 这样就做到了窗体中控件的线程安全性。 ------------------ InvokeRequired 当前线程不是创建控件的线程时为true 比如你可以自己开一个Thread,或使用Timer的事件来访问窗体上的控件的时候,在线程中窗体的这个属性就是True的。 简单的说,如果有两个线程,Thread A和Thread B,并且有一个Control c,是在Thread A 里面new的。

C#的New关键字的几种用法

C#的New关键字的几种用法 2009年01月24日星期六 09:34 前段时间一个朋友问到C#的New关键字有几种用法,虽说在日常编程中经常用到这个小家伙,但它到底有几种用法还真没有留意过,现将从网上总结出的资料记下以供同仁学习。 (1)new 运算符用于创建对象和调用构造函数。 (2)new 修饰符用于隐藏基类成员的继承成员。 (3)new 约束用于在泛型声明中约束可能用作类型参数的参数的类型。 new 运算符 1.用于创建对象和调用构造函数 例:Class_Test MyClass = new Class_Test(); 2.也用于为值类型调用默认的构造函数 例:int myInt = new int(); myInt 初始化为 0,它是 int 类型的默认值。该语句的效果等同于:int myInt = 0; 3.不能重载 new 运算符。 4.如果 new 运算符分配内存失败,则它将引发 OutOfMemoryException 异常。 new 修饰符 使用 new 修饰符显式隐藏从基类继承的成员。若要隐藏继承的成员,请使用相同名称在派生类中声明该成员,并用 new 修饰符修饰它。 请看下面的类: 1 public class MyClass 2 3 { 4 5 public int x; 6 7 public void Invoke() {}

9 } 10 在派生类中用 Invoke 名称声明成员会隐藏基类中的 Invoke 方法,即: 1 public class MyDerivedC : MyClass 2 3 { 4 5 new public void Invoke() {} 6 7 } 8 但是,因为字段 x 不是通过类似名隐藏的,所以不会影响该字段。 通过继承隐藏名称采用下列形式之一: 1.引入类或结构中的常数、指定、属性或类型隐藏具有相同名称的所有基类成员。 2.引入类或结构中的方法隐藏基类中具有相同名称的属性、字段和类型。同时也隐藏具有相同签名的所有基类方法。 3.引入类或结构中的索引器将隐藏具有相同名称的所有基类索引器。 4.在同一成员上同时使用 new 和 override 是错误的。 注意:在不隐藏继承成员的声明中使用 new 修饰符将生成警告。 示例 在该例中,嵌套类 MyClass 隐藏了基类中具有相同名称的类。该例不仅说明了如何使用完全限定名访问隐藏类成员,同时也说明了如何使用 new 修饰符消除警告消息。 using System; public class MyBaseC { public class MyClass { public int x = 200; public int y;

however的用法

With the possible exception of the Beatles, no other band has become so successful so quickly. 可能除了披头士乐队这个例外,还没有哪个乐队如此转瞬走红的。 并列句中连接词语的功能 2006-03-01 18:54:21 ??英语中,包含两个或两个以上互不依从的主谓结构的句子称为并列句,各个相互独立的主谓结构叫作分句,多数情况下并列句中的分句由并列连接词来连接。并列句的分句之间关系密切,而并列连接词是分句之间关系的纽带,它们起着承上启下的作用,显示了分句之间逻辑关系,指示了说话人思维的走向。因此,正确理解和掌握连接词语是我们能否正确理解话语篇章意义的关键。表示并列关系的词语除了并列连词(如:and,but,or,so,for等),还有并列词组(如:in addition,as a result 等)和连接性副词(如:however,moreover,otherwise等),这里统称为连接词语。根据连接词语的语义功能,可将其分类如下: 1.表示补充、添加关系的连接词 这类连接词表示后面分句的句意是对前面分句句意的补充,说的是同类事情。常用的有:and,in addition,besides,moreover,furthermore,likewise,in the same way,what’s more 等。例如: Irene did not answer,and James,too,ceased speaking. 艾琳没有回答,詹姆斯也不再说话。(说的都是"保持沉默") Bicycling is good exercise,moreover,it doesn’t pollute the air. 骑自行车是项很好的运动,而且又不污染空气。(说的都是骑自行车的优点) A flood will break a dam;likewise, the oppressed people everywhere will overthrow their oppressors in the end. 洪水会冲毁大坝,同样,任何地方的被压迫人民也会推翻他们的压迫者。(说的是同一道理) 2.表示转折关系的连接词 这类连接词表示后面分句在意义上与前面的分句发生了转折,说的是不同情况或不同的观点。常见的有:but,however,nevertheless,instead,on the contrary,on the otherhand,yet,by contrast,whereas等。例如: The situation looked desperate,but they didn’t give up hope. 形势看来非常危急,但他们没有放弃希望。 It’s too wet to go for a walk;let’s go swimming instead. 天气潮湿,不宜去散步,我们改去游泳吧。 There was no news;nevertheless,she went on hoping. 尽管没有消息,她仍抱着希望。 3.表示因果关系的连接词

大工15春《大学英语3》作业1、2、3满分答案资料

大工15春《大学英语3》在线测试1答案(第1至4页) 大工15春《大学英语3》在线测试2答案(第5至8页) 大工15春《大学英语3》在线测试3答案(第9至11页) 大工15春《大学英语3》在线测试1 一、单选题(共20 道试题,共80 分。)V 1. This A TM has been out of service for a few days. It should _____ last week. A. fix B. be fixed C. have fixed D. have been fixed 满分:4 分 2. You will probably _____ your team's chance to win because you seem to have such a big _____ them. A. affect; impact in B. effect; impact in C. affect; impact on D. effect; affect on 满分:4 分 3. Don't climb to the top of the hill with one breath. _____ your energy. You'll need it! A. Reserve B. Protect C. Burn D. Conserve 满分:4 分 4. This is the microscope ______ which we have had so much trouble. A. at B. from C. of D. with 满分:4 分 5. There are several ways of _____ the problem. Have you studied which one will benefit us most? A. coming B. approaching C. attacking D. dealing 满分:4 分 6. He's been sought after by many young girls. I am really surprised you have an unfavorable ______ of him.

dwr使用方法

Dwr 框架基础用法
1. Web.xml 中的配置:
Direct Web Remoter Servlet DWR Servlet dwr-invoker uk.ltd.getahead.dwr.DWRServlet debug false 10 dwr-invoker /dwr/*
2. Dwr.xml 中的配置:


异步调用机制及实现方法

这篇文章将介绍异步调用的实现机制及如何调用异步方法。大多数.NET开发者在经过delegate、Thread、AsynchronousInvocation之后,通常都会对以上概念产生混淆及误用。实际上,以上概念是.NET2.0版本中对并行编程的核心支持,基于概念上的错误认识有可能导致在实际的编程中,无法利用异步调用的特性优化我们的程序,例如大数据量加载引起的窗体”假死”。事实上这并不是一个困难的问题,该文将以一种逐层深入、抽丝剥茧的方式逐渐深入到异步编程的学习中。 同步与异步 大多数人并不喜欢阅读大量的文字说明,而喜欢直接阅读代码,因此,我们在下文中将主要以代码的形式阐述同步与异步的调用。 同步方法调用 假设我们有一个函数,它的功能是将当前线程挂起3秒钟。 static void Sleep() { Thread.Sleep(3000); } 通常,当你的程序在调用Sleep后,它将等待3秒钟的时间,在这3秒钟时间内,你不能做任何其他操作。3秒之后,控制权被交回给调用线程(通常也就是你的主线程,即WinForm程序的UI线程)。这种类型的调用称为同步,本次调用顺序如下: ● 调用Sleep(); ● Sleep()执行中; ● Sleep()执行完毕,控制权归还调用线程。 我们再次调用Sleep()函数,不同的是,我们要基于委托来完成这次调用。一般为了将函数绑定在委托中,我们要定义与函数返回类型、参数值完全一致的委托,这稍有点麻烦。但.NET内部已经为我们定义好了一些委托,例如MethodInvoker,这是一种无返回值、无参数的委托签名,这相当于你自定义了一种委托: public delegate void SimpleHandler(); 执行以下代码: MethodInvoker invoker = new MethodInvoker(Sleep); invoker.Invoke(); 我们使用了委托,但依然是同步的方式。主线程仍然要等待3秒的挂起,然后得到响应。 注意:Delegate.Invoke是同步方式的。

invoke 用法

在写代码的时候,发现Method可以调用子类的对象,但子类即使是改写了的Method,方法名一样,去调用父类的对象也会报错,虽然这是很符合多态的现象,也符合java的动态绑定规范,但还是想弄懂java是如何实现的,就学习了下Method的源代码。Method的invoke方法 1.先检查AccessibleObject的override属性是否为true。 AccessibleObject是Method,Field,Constructor的父类,override属性默认为false,可调用setAccessible方法改变,如果设置为true,则表示可以忽略访问权限的限制,直接调用。 2.如果不是ture,则要进行访问权限检测。用Reflection的quickCheckMemberAccess 方法先检查是不是public的,如果不是再用Reflection.getCallerClass(1)方法获 得到调用这个方法的Class,然后做是否有权限访问的校验,校验之后缓存一次,以便下次如果还是这个类来调用就不用去做校验了,直接用上次的结果,(很奇怪用这种方式缓存,因为这种方式如果下次换个类来调用的话,就不用会缓存了,而再验证一遍,把这次的结果做为缓存,但上一次的缓存结果就被冲掉了。这是一个很简单的缓冲机制,只适用于一个类的重复调用)。 3.调用MethodAccessor的invoke方法。每个Method对象包含一个root对象,root 对象里持有一个MethodAccessor对象。我们获得的Method独享相当于一个root对象的镜像,所有这类Method共享root里的MethodAccessor对象,(这个对象由Reflectio nFactory方法生成,ReflectionFactory对象在Method类中是static final的由native 方法实例化)。 ReflectionFactory生成MethodAccessor:如果noInflation的属性为true则直接返回MethodAccessorGenerator创建的一个MethodAccessor。 否则返回DelegatingMethodAccessorImpl,并将他与一个NativeMethodAccessorI mpl互相引用。但DelegatingMethodAccessorImpl执行invoke方法的时候又委托给N ativeMethodAccessorImpl了。 再一步深入 4.NativeMethodAccessorImpl的invkoe方法: 调用natiave方法invoke0执行方法调用. 注意这里有一个计数器numInvocations,每调用一次方法+1,当比ReflectionFactory. inflationThreshold(15)大的时候,用MethodAccessorGenerator创建一个MethodAcc essor,并把之前的DelegatingMethodAccessorImpl引用替换为现在新创建的。下一次DelegatingMethodAccessorImpl就不会再交给NativeMethodAccessorImpl执行了,而是交给新生成的java字节码的MethodAccessor。MethodAccessorGenerator使用了asm字节码动态加载技术,暂不深入研究。 总结一个方法可以生成多个Method对象,但只有一个root对象,主要用于持有一个Me thodAccessor对象,这个对象也可以认为一个方法只有一个,相当于是static的。因为M ethod的invoke是交给MethodAccessor执行的,所以我所想要知道的答案在Method Accessor的invoke中,深入MethodAccessor: ------------------------------------------MethodAccessor--------------------------------- 假如有这么一个类A: public class A { public void foo(String name) { System.out.println("Hello, " + name);

it 做形式主语和however 用法

不管however以何种形式出现,它都不外乎以下两种用法。 1. 用作副词 (1) 表示让步:意为“无论如何”“不管怎样”,用来修饰形容词或副词, 其词序为:however+形容词或副词+主语+谓语。这样用的however其实具有连词的功能,用以引导让步状语从句。如: however much he eats, he never gets fat. 不管他吃多少,他永远吃不胖。 用于此用法时,请注意以下几点: ①此用法属however所有用法中最重要的考点,同学们务请引起高度重视。 ②这样用的 however 与 no matter how 大致同义。如: People always want more, however [no matter how] rich they are. 人总是富了还想再富。 however [No matter how] hard I worked, she was never satisfied. 无论我多么努力地工作,她从来没满意过。 ③有时从句谓语可用情态动词。如: Don’t laugh, however funny it may be. 无论多么有趣也不要笑。 I’ll try to finish it in time, however hard it may be. 无论多么难,我也要按时完成。 ④“however+形容词或副词+主语+谓语”有时可以有所省略。如: I refuse, however favorable the conditions. 不管条件如何有利,我都不干。(conditions 后省去了are) I’d rather have a room of my own, however small (it is), than share a room. 无论房间多么小,我宁愿一个人住一间,而不愿意与别人合住一个房间。 A grammar rule, however true (it is), is useless unless it can be understood. 一条语法规则,不管如何正确,除非能懂,否则毫无用处。 (2) 表示转折:尤其用于谈及一个既成事实时,表示转折,其意为“可是”“仍然”等。可放在句首、句中或句末,通常用逗号与句子其他成分隔开。如: My father, however, did not agree. 但是,我父亲不同意。 My room is small; however, it’s comfortable. 我的房间很小,但却很舒服。 He said that it was so; he was mistaken, however. 他说情况如此,可是他错了。注:however不能像 but(但是)那样直接连接两个句子(注意正句中的标点符号)。如: 我们都已尽了最大的努力,不过我们还是输了。. 正:We all tried our best, but we lost the game. 正:We all tried our best; however, we lost the game. 正:We all tried our best. however, we lost the game. (3) 表示惊奇或强调:相当于how ever的用法,其意为“究竟怎样,到底以什么方式”。如:however did you get here without a car? 没有汽车你究竟是怎样来的呢? No matter +疑问词或者疑问词-ever 含义为“无论……都, 不管……都”。他们引导让步状语从句,并且可以互换。

VCS使用介绍

J. M. Williams 2006-09-19 VCS Simulator Summary Your startup environment includes this alias: alias vcs='vcs -RI +charge_decay +memcbk +pathpulse +v2k' To remove this alias (you usually would not want to), invoke \vcs instead of vcs. You must provide a valid verilog file name when you invoke VCS; if the file has a serious syntax error, VCS will exit immediately with an informative error message. For one verilog file, invoke vcs filename To invoke VCS on a design of several files, the names (with path if necessary) must be listed top-down in a file. Then, invoke VCS on the file (using -f): vcs -f file_with_design_files_listed Graphical UI hints (for Introductory Lab 1): Immediately after invoking vcs -f Intro_Top.vcs notice in the GUI that the current simulation time of 0 appears at the bottom of the Interactive Window; it is in 100-ps units, as specified in TestBench.v. VCS always pauses at time 0. Also notice that the scope is TestBench, which contains the top of the design as a verilog module instance. To run the Intro simulation, 1. Open a Hierarchy Browser window, using the menu bar along the top. On the left of the new window, pick [+] to display the design hierarchy. If no [+] appears, pick [Sim] on the menu bar and [Rebuild & re-exec] to reestablish communication. Note: We shall not be concerned with the Register Window or Logic Browser. 2. Use the top menu bar to open a Wave Window. Then, holding down the middle mouse button, drag the text "TestBench" from the Hierarchy Browser window into the Wave Window. The dragged image should turn color in the area where it is allowed to drop the text. 3. Pick [continue] or [=>] with the mouse. This runs the simulation. Notice that the time now is 5,540 x 100 ps = 554 ns. 4. View the simulation results. To zoom on the entire simulation waveform, in the Wave Window, pick the small [z%] button and choose "100%" on the popup menu. You should see the initially unknown 'x' and 'z' states on the left, and the various top-level input and output wave shapes as the simulation proceeded. 5. Reminder: If you change anything in a design, always run Rebuild & re-exec from the Sim menu to compile and view your changes. Try this now. 6. After seeing that the simulation has run again, use the File/[Exit] menu choice to close all VCS windows at once. Don't bother saving configuration when prompted. Special hints (for labs after Lab 1): When simulating a netlist using a verilog library file of numerous component models, it is useful to add "-v " before the library line in the .vcs file: VCS compiles only those models actually in the design. Use vcs -help to see all available VCS options. On exitting the VCS GUI, if you save configuration to a some_name.cfg configuration file, you can program the VCS GUI to start with the saved window setup and waveform signals by adding "+cfgfile+some_name.cfg" to your VCS command alias. "+cfgfile+default.cfg" works well.

but,however,while,although和though用法小结

but, however, while, although和though用法小结 【观察】阅读下列句子,注意各句中黑体单词的用法。 1. We have made some achievements, but we should be modest. 2. He promised to help me. However, he is busy and hasn’t come. 3. She felt ill. She went to work, however, and tried to concentrate. 4. He said that it was so; he was mistaken, however. 5. You like sports, while I’d rather read. 6. While I understand what you say, I can’t agree with you. 7. Although / Though it was late, she went on working. 8. Tired though he was, he went on working. 9. Although he’s got a good job now, he still complains. 10. She promised to phone. I heard nothing, though. 【归纳总结】 ★but与however均可表示转折,意为“但是,然而”,都可以引出表转折意义的句子(句1-句4),但二者用法也有区别: 1. 从语义上看,but所表示的是非常明显的对比,转折的意味较however要强。 2. 从语法上看,but是个并列连词,而however却是个连接副词(句2-句4)。 3. 从语序上看,but总是位于它所引出的分句之首,而however可位于句首、句中或句尾。

PHP中的魔术方法用法

PHP中的魔术方法 一、魔术方法的种类 __construct(),__destruct(),__call(),__callStatic(),__get(),__set(),__isset(),__unset(),__sleep(),__wakeup(),__toString(),__invoke(),__set_state(),__clone() 和__debugInfo() 等方法在PHP 中被称为"魔术方法"(Magic methods)。在命名自己的类方法时不能使用这些方法名,除非是想使用其魔术功能。 注意:PHP 将所有以__(两个下划线)开头的类方法保留为魔术方法。所以在定义类方法时,除了上述魔术方法,建议不要以__ 为前缀。 二、魔术方法的用法 2.1 __sleep() 和__wakeup() __sleep(),当对象被序列化时,对象会自动调用__sleep函数,该函数返回的数组参数中包含哪些属性被序列化。 注意: __sleep() 不能返回父类的私有成员的名字。这样做会产生一个E_NOTICE 级别的错误。 __sleep() 方法常用于清理对象操作。如果有一些很大的对象,但不需要全部保存,这个功能就很好用。 __wakeup()对象被反序列化时被调用,用来对对象中的一些属性重写初始化. __wakeup() 经常用在反序列化操作中,例如重新建立数据库连接,或执行其它初始化操作。魔术方法: __construct对象创建调用 __destruct 对象销毁时调用 2.2 魔术方法的属性重载 当访问一个不可访问的属性时,PHP会自动调用下面相应的魔术方法 属性的操作: 赋值:__set($name,$value) 访问:__get($name) 删除:__unset($name) 判断是否存在:__isset($name) 1. __set魔术方法 在为一个不可访问的属性赋值时,可会自动调用对象的__set方法,如果__set方法没有定义则执行默认重载操作。 注意:__set($name,$value)的这种形式是PHP规定的写法,由PHP检测到设置的属性不存在,将要设置的属性名字和值分别传入__set方法中. __set方法能够做什么呢?

英语中however的用法

英语中however的用法 1. 表示“在……期间”,是介词,不要将其误用作连词。如: 他在巴黎期间,与他的朋友住在一起。 误:During he was in Paris, he lived with his friends. 正:While he was in Paris, he lived with his friends. 正:During his stay in Paris, he lived with his friends. 2. during 和for 均可表示一段时间,但两者有差别。 (1) during 通常表示事件发生在何时(when),而for则表示事件持续了多长时间(how long)。如: He was in hospital for six weeks during the summer. 他在夏天住了6 个星期的医院。 (2) 两者之后均可接由the whole 引起的时间短语,但通常不能接由all 引起的时间短语。如: 他整个夏天都住在那儿。 正:He stayed there for [during] the whole summer.

误:He stayed there for [during] all the summer. (3) 在“数词+时间名词”之前以及在some time, a long time之类表示泛指一段时间的词组之前,可用介词for,但不用during。如: He lived here for ten years (for some time). 他在这儿住过10 年(一段时间)。 3. during与in均可表示“时间点”,有时可互换。如: I'll be on holiday in [during] August. 我将在8月度假。 He woke up three times in [during] the night. 夜里他醒了3 次。 但在使用时还有以下几点要注意: (1) 比较而言,during 更强调时间的延续,in 只是指一般性的某一时间。因此若表示状态或习惯性动作,多用during,否则以用in为常见。如: Many people suffered hardship during the war. 许多人在战争期间受苦遭难。 He was injured in the war. 他在战争期间受了伤。 (2) 在stay, visit, meal等表示行为要持续一段时间的名词之前,只能用during 而不能用in。如:

相关主题
文本预览
相关文档 最新文档